Django admin media not loading

I am trying to deploy this application with nginx / gunicorn, but I do not know why there are no admin media files.

settings.py:

ADMIN_MEDIA_PREFIX = '/srv/www/antingprojects.com.ar/gobras/static/admin/' 

I also tried:

 ADMIN_MEDIA_PREFIX = '/static/admin/' 

project folder:

 /srv/www/antingprojects.com.ar/gobras/static/admin/css|js|img 

urls.py:

 (r'^static/admin/(?P<path>.*)$', 'django.views.static.serve') 

nginx access.log:

 "GET /admin/ HTTP/1.1" 200 1556 "-" "GET /srv/www/antingprojects.com.ar/gobras/static/admin/css/base.css HTTP/1.1" 404 1136 "http://antingprojects.com.ar/admin/" "GET /srv/www/antingprojects.com.ar/gobras/static/admin/css/dashboard.css HTTP/1.1" 404 1141 "http://antingprojects.com.ar/admin/" "GET /admin_media/img/admin/nav-bg.gif HTTP/1.1" 404 1114 
+4
source share
3 answers

Thanks for the help, the problem was in nginx.conf, I did not find the / static folder.

  location /static { root /srv/www/antingprojects.com.ar/gobras; } 
+1
source

You need to configure a symbolic link from the directory in which the administrator’s multimedia files are located in the static media directory that you use to serve your static files.

Administrator media files should have something like:

 path/to/django/contrib/admin/media/ 

Once your symlink is configured, you will install ADMIN_MEDIA_PREFIX in the symbolic directory in the directory where you serve your static files, so something like this should work:

 ADMIN_MEDIA_PREFIX = '/static/admin/' 

Check where your administrator is trying to download their media files, and this should help you get started if you cannot determine which directory to use.

Here is a quick guide to symbolic links:

http://ubuntuforums.org/showthread.php?t=255573

+6
source

Your ADMIN_MEDIA_PREFIX correct, you just need to remove the /admin part from your static URL, because what you have specified now translates into a URI starting with /static/admin/admin to access your /static/admin/admin resources through a static view.

+1
source

All Articles