static files - what's the correct setup

[mod edit] This question is largely outdated since we released our static files support, which you'll find on the Web tab


My settings file is in "home/<me>/Dropbox/code/mysite-tutorial01/mysite/" and my CSS and .js files are in "home/<me>/Dropbox/code/assets/".

My debug is True and in, I have a url pattern setup with works on localhost.

if settings.DEBUG:
    urlpatterns += patterns('',
        (r'^assets/(?P<path>.*)$', 'django.views.static.serve',
             {'document_root':     settings.MEDIA_ROOT}),

I'm also importing static files (but I'm sure I'm not using it correctly)

from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()

The static files for my admin work just fine But the static files for my app don't work. Please help, then I will be live!!!

Update 1: There was a typo in I didn't end my path with '/' (I never now when to keep it or remove it...)

Anyways, I'm wonder what changes I need to make if i set debug to false. after i make this change, both apps (admin and my web app) don't load the css.


For the moment, just remove the

if settings.DEBUG:

from the first piece of code in your first post. Then you'll serve static files through Django.

We are putting the finishing touches to a better way of serving static files and we hope to have it available some time next week.


I'm also looking for a solution to serve static files (CSS files especially but also some other files) through a Django project with DEBUG=False activated.

Is this implemented yet? I want to False-ify debug so I can have custom 404/500 templates and actions.

Thanks in advance!

Not quite, unfortunately. If you want the gory details, the problem is that to do it properly we're having to move our front-end servers from Apache to nginx. This is quite a lot of work, and while it's going to be a big improvement to the site overall -- nginx is just fundamentally better at handling the kind of things we do -- it's something that needs a lot of testing before we release it. We'll get there, though!