开发者

Error trying to load django admin images with NGINX

I am using NGINX, uwsgi (to serve my django files) and apache in my webserver.

But when I try to access the django admin page the images arent loading. The NGINX log says error 404 ("GET /static/admin/css/base.css/ HTTP/1.1" 404)

Here is my NGINX configuration:

    server {
    listen   80;
    server_name www.xyz.com xyz.com;
    access_log /var/log/nginx/xyz.com-access.log;
    error_log /var/log/nginx/xyz.com-error.log;

    location / {
        include        uwsgi_params;
     开发者_StackOverflow中文版   uwsgi_pass     127.0.0.1:9001;
    }

    location /media {
        root   /srv/www/xyz.com.com.br/application/x;
    }
    location /templates {
        root   /srv/www/xyz.com.com.br/application/x;
    }       
    
        
}

The media directory (that contains css, js and imgs) are located in /usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/contrib/admin/media/

I tried to give a location to it but I didnt have success...


Possibly because of the “/” suffix? Does it work if you request http://example.com/static/admin/css/base.css (without the trailing slash)?

Additionally, you don't seem to have the /static URL setup in your nginx config:

location /static {
    root /usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/contrib/admin/media/
}


Thanks, I was missing "ADMIN_MEDIA_PREFIX = '/srv/www/xyz.com.br/application/X/' " in settings.py

Also I copied /usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/contrib/admin/media/ to /srv/www/xyz.com.br/application/x/static

and did this change in nginx:

    location /static {
         root /srv/www/xyz.com.br/application/x;
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜