Search code examples
cssdjangostaticnginxpinax

css not loaded in django production


here is my baffling problem: Everything is fine on my Pinax development machine, but when I moved the files to production, (using nginx webserver + flup) no style sheet is loaded.

I have run

python manage.py build_static

My project, going to server foo.com, lives in /www/foo and all my static files are copied

/www/foo/site_media/static

and here are the relevant parts in sttings.py

PINAX_ROOT = os.path.abspath(os.path.dirname(pinax.file)) PROJECT_ROOT = os.path.abspath(os.path.dirname(file))

PINAX_THEME = "default"

DEBUG = False

MEDIA_URL = "/site_media/"

STATIC_ROOT = os.path.join(PROJECT_ROOT, "site_media", "static")

STATIC_URL = "/site_media/static/"

ADMIN_MEDIA_PREFIX = posixpath.join(STATIC_URL, "admin/")

In nginx's foo.com I have:

location /site_media {
      autoindex on;
    root  /www/foo/;
}

location /static/ {
   root /www/foo/site_media/static/;
}

Each time that I try a different tweak,I restart nginx and fcgi (hopefully) :

python /www/foo/manage.py runfcgi host=127.0.0.1 port=7718 pidfile=/www/foo/foocom.pid maxspare=2

There is no specific rules in urls.py about static files. Do I need to add something here?

I have tried literally dozens of different combination of paths, but no chance. Really got frustrated and appreciate your clues.


Solution

  • As a first step, try to load the style sheet URL directly in your browser (open "view source" in the HTML page to get the full URL). Check what error you get - it may be enlightening.