Another Software Engineer Another Technology Blog

  • Blog A
  • Linkblog
  • Photoblog
  • Trading
  • Candy
  • Gambling
  • DSO
  • HO
  • Technology
Blog Name
  • Home
  • Contact
  • Log in

Using Django to Serve Static Files in Development

by David Orkin on Oct.06, 2009,under Python, Django

So by default Django doesnt serve static files because, well, it doesn't serve them as well as a web server like Apache would. But one small thing struck me as odd in the online documentation that describes how to serve static files in the snippet below

 

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

Why wouldn't you use the MEDIA_ROOT variable from settings.py? Granted this may not be the biggest issue, but if given the choice, I think my preference would be to keep the settings for the application in settings.py, you know the file for application settings. Yes I know this shouldn't be used outside of development, but still wonder what the advantage of doing it this way would be...

Below is the code I am currently using,

if settings.DEBUG:
    urlpatterns += patterns('',
        (r'^site_media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
    )
« Installing Adobe Reader 9.1.2 (acroread) on Ubuntu 9.0.4
Template Inheritance in Django (aka The Django equivalent of a Rails layout) »
  • July 2010
    Sun Mon Tue Wed Thu Fri Sat
     << <   > >>
            1 2 3
    4 5 6 7 8 9 10
    11 12 13 14 15 16 17
    18 19 20 21 22 23 24
    25 26 27 28 29 30 31
  • Another Software Engineer Another Technology Blog

    • Recently
    • Archives
    • Categories
    • Latest comments
  • Search

  • Categories

    • All
    • Operating Systems
      • Ubuntu
        • 9.10 Karmic Koala
    • Programming Languages
      • Python
      • Ruby
    • Rants
    • Technology
      • PDF
    • Tutorials
    • Uncategorized
    • Web Application Frameworks
      • Django
      • Ruby on Rails
        • Capistrano
  • XML Feeds

    • Atom: Posts
    • RSS 2.0: Posts
    What is RSS?
powered by b2evolution free blog software

A b2evolution port by JC John Sese Cuneta.

Theme: pixel and Sweet Icons by famfamfam.

Contact • Powered by b2evolution

Credits: skin makers • blog software • hosts