Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django admin media not loading

I'm trying to deploy this application with nginx/gunicorn but I don't know why the admin media files are missing.

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 
like image 996
mfalcon Avatar asked Feb 23 '23 17:02

mfalcon


1 Answers

You need to set up a symbolic link from the directory where the admin media files are to the static media directory you are using to serve your static files.

The admin media files should be at something like:

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

Once your symlink is set up you would set your ADMIN_MEDIA_PREFIX to the symbolic directory within the directory where you serve your static files, so something like this should work:

ADMIN_MEDIA_PREFIX = '/static/admin/'

Check to see where your admin is trying to load its media files from, and this should help you get started if you can't figure out which directory to use.

Here's a quick tutorial on symlinks:

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

like image 89
rolling stone Avatar answered Feb 26 '23 21:02

rolling stone