After doing the python manage.py collectstatic I found out that I can access everything in static/css but not in static/admin. To be very clear:
- I go to: http://mysite.com/static/admin/css/login.css and fails
- Manually move the folder
static/admintostatic/css - I go to: http://mysite.com/static/css/admin/css/login.css and works!
Notice the change from /static/admin/css/ to /static/css/admin/css/ in the URLS. This means that this doesn’t solve the problem because the templates continue pointing to the first URL.
I know, serving static admin files has been asked 100 times in stackoverflow but I still cannot make it work (and I am not alone for the comments I have read). It seems nobody has mention this weird problem of accessing the static/css folder and static/anyother_folder.
Some extra details:
There is no errors in the collectstatic, there is no problems with the application css’s. This is what I have in my settings.py):
MEDIA_ROOT = join(PROJECT_ROOT,'../media')
MEDIA_URL = '/media/'
STATIC_ROOT = join(PROJECT_ROOT,'../static')
STATIC_URL = '/static/'
I also have tried the deprecated ADMIN_MEDIA_PREFIX without any result.
ADMIN_MEDIA_PREFIX = '/static/admin/'
My nginx configuration is simple and clear.
location /static {
alias /home/the_home/where_the_static_is/static/;
}
location /media {
alias /home/the_home/where_the_media_is/media/;
}
I am using the last version of Django (1.4.2).
Puff. So, here it was. I had another folder in nginx redirecting the /static/admin/ to the Django installation in the virtual environment. In the organization, we use a virtual machine template that pre-configure our Django projects. So, revisiting the nginx configuration I found this:
Apparently this worked for Django 1.3 but the path changed at some point.