Search code examples
djangodjango-staticfileswebfaction

Static files not being served from seperate django staticfile application


I'm using webfaction to make a simple static website. I think I have done everything correctly, but still my static files (i.e css, images) are not being served. I used this guide to set things up:

http://docs.webfaction.com/software/django/getting-started.html

I did everything they told me to, so in brief:

1) made a separate static media application

2) updated settings.py

3) ran

python manage.py collectstatic 

All of the above went pretty much according to plan and I can now see my static files in the staticfile application that I named personalsitestatic. My django application is called personalsite.

The directory structure looks like this:

  • webapps
    • htdocs
    • personalsite
      • apache2
      • bin
      • lib
      • PersonalWebsite
        • manage.py
        • PersonalWebsite
          • settings.py, urls.py, ect
        • main
          • settings.py, urls.py, static files directory, ect
    • personalstiestatic
      • bootstrap
      • custom

This is what the relevant values in my settings.py looks like:

STATIC_ROOT = '/home/<myname>/webapps/personalsitestatic/'
STATIC_URL = 'http://<sitename>.com/static/'
TEMPLATE_DIRS = (
"/home/<myname>/webapps/personalsite/PersonalWebsite/templates/",)

I don't have any additional static directories outside of main/static so I am not using STATIC_DIRS. The templates appear to be loading fine, just none of the static files. When I inspect with firefox's debugger/inspect element thing it just says "stylesheet could not be loaded". Can anyone help me out here or at least give me some suggestions for debugging?


Solution

  • I was being silly and did not mount it to the /static url, hope this helps someone!