views:

116

answers:

4

Hi everyone,

I'm using Django on a Debian VM, django server is loaded through nginx. Everything's working 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.

+3  A: 

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: http://stackoverflow.com/questions/1833675/django-admin-has-no-style

meder
Unfortunately it didn't made the trick...I've tried copying admin folder from /usr/local/lib/python-2.6/django/contrib/admin into my project folder and updated ADMIN_MEDIA_PREFIX to './admin/media/'. Stop Django server, restarted Nginx and restart Django server...
oleiade
How are you serving static files? Where are your static files? Did you set *any* up yet? It totally depends on your configuration. You have not provided the sufficient information for your server setup. I can't guess how you set it up, as there are dozens of ways to do so. This question lacks the proper information to answer properly.
meder
I haven't setted up any serving static files. All requests are served to Django via FastCgi and my nginx conf looks like this:
oleiade
+2  A: 

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.

Deniz Dogan
AS I've answered to meder, didn't made the trick, any other ideas? thanks
oleiade
A: 

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;
    }
oleiade
you ought to edit the initial answer instead of answering your own question.
Uku Loskit
+3  A: 

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/;
}
bennylope
Would also suggest tagging this question with 'nginx'.
bennylope
Sounded nice, but unfortunately, didn't make the trick either... I'm quite disgusted of Django now. I can do nice things, and everything works fine on Local Django server, but making it going through nginx doesn't seem to be a reliable solution...
oleiade
It doesn't sound like Django is the problem so much as the server configuration (which admittedly can be a pain the first go around). This was a great resource for me: http://www.saltycrane.com/blog/2009/04/notes-using-nginx-mod_python-and-django/ My advice would be to just try accessing a media file from your project, e.g. mysite.com/site_media/styles/base.css - my guess is that right now they don't show up. Just focus on the settings (Django but mainly nginx) that will properly point the URLs to the media files; its the same issue with the admin files most likely.
bennylope