Thoughts and tutorials on programming

Thursday, June 07, 2007

how to host static files in a django app for development

add the following to (first line optional :)

if settings.DEBUG: # then serve static files here :)
urlpatterns += patterns('',
(r'^static_files/(?P.*)$', 'django.views.static.serve', {'document_root': 'C:/office_in_out/oliver/drb/static_files', 'show_indexes': True}),

Then you can access /static_files/filename.jpg and it should work. See the other post for production setup :)

As a side note, "how to change your django app from development to production" is you go to and change DEBUG = True to DEBUG = False. I'm not sure what to do with TEMPLATE_DEBUG after that :)

No comments: