Django: ugly admin interface
I'm using Django on a Debian VM, django server is loaded through nginx. Everything's worki开发者_C百科ng fine 'til now, except the admin interface. In fact, the admin site, doesn't load the "look and feel" of the interface. It seems that Css and images aren't loading at all, any ideas?
Thanks.
Change ADMIN_MEDIA_PREFIX
to wherever your media is. If you didn't copy the media, copy it from wherever django is stored, there's a media and admin directory.
Similar question: Django admin has no style
Try adding the media aliases. I had the same problem when setting up an nginx proxy to Apache, and after adding the media aliases I solved the problem.
Here's a sample that I have in my an nginx site configuration file:
location /media/ {
alias /opt/django-env/django_project/media/;
}
location /admin_media/ {
alias /opt/django-env/lib/python2.6/site-packages/django/contrib/admin/media/;
}
You have probably set the wrong ADMIN_MEDIA_PREFIX setting or simply not set the server up to serve anything from that URL. If you have set all of that correctly, make sure you have copied (or linked) the Django admin media to your project.
I haven't setted up any serving static files. All requests are served to Django via FastCgi and my nginx conf looks like this:
server {
listen 192.168.61.130:80; ## listen for ipv4
##listen [::]:80 default ipv6only=on; ## listen for ipv6
server_name 192.168.61.130;
access_log /var/log/nginx/localhost.access.log;
error_log /var/log/nginx/localhost.error.log;
location / {
root /var/www/socratie;
index index.html index.htm;
fastcgi_pass 127.0.0.1:8000;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
}
精彩评论