Clarification: The following error is onlyfor the admin static files, i.e. it is specific to the static files corresponding to the Django admin. The rest of the static files are working perfectly.
Problem
Basically, I cannot access the admin static files using the ngix server.
It does work with the micro server of Django, and the collectstatic
is doing its job, meaning it is putting the files on the expected place in the static folder.
The urls are correct but I cannot access the admin static files directly, but the others I can. So, for example:
I am able to access this url (copying it in the browser):
myserver.com:8080/static/css/base/base.css
but I am not able to access this other url (copying it in the browser):
myserver.com:8080/static/admin/css/admin.css
What have I tried?
It does work if I copy the admin/
directory structure into __other_admin_directory_name/__
, and then I access
myserver.com:8080/static/__other_admin_directory_name__/css/admin.css
Moreover,
- I checked permissions and everything is fine.
- I tried to change ADMIN_MEDIA_PREFIX = '/static/admin/' to ADMIN_MEDIA_PREFIX = '/static/other_admin_directory_name/', it doesn't work.
Finally, and it seems to be an important clue:
I tried to copy the admin/
directory structure into __admin_and_then_any_suffix/__
. Then I cannot access
myserver.com:8080/static/__admin_and_then_any_suffix/__/css/admin.css
. So, if the name of the directory starts with admin
(for example administration or admin2
) then it doesn't work.
EDIT - added thanks to @sarnold observation:
The problem seems to be in the nginx configuration file /etc/nginx/sites-available/mysite
location /static/admin {
alias /home/vl3/.virtualenvs/vl3/lib/python2.7/site-packages/django/contrib/admin/media/;
}
nginx
configuration./static/admin
? Wouldn't the standard '/static' cover it all? I just use a single:location /static/ { alias /path/to/static/; }