tags:

views:

23

answers:

3

I am learning Django, using the django book, which is great. However, it is a little down on using the django test server to serve up image files and other media. Obviously, any page has some amount of image content beyond the straight up HTML that you put in templates. And there are various other files that need to be served up such as CSS files and possibly non native files (such as PDF, spreadsheets, RDF, xml and the like.)

Of course I can set all that up in Apache, however, I need to be able to serve most of these (especially gifs, pngs etc.) during the development process. There doesn't seem to me to be an obvious way to configure that.

Can someone tell me how django developers do this? What is the standard practice? Do I have to use Apache as the development server?

Thx.

+1  A: 

The documentation is very helpful on this.

Daniel Roseman
Perfect. Thanks.
Fred Thomas
+1  A: 

There is absolutely nothing wrong with using the development server for development. It's extremely handy, and meant specifically for that purpose.

What the Django developers and Django Book are trying very hard to steer people away from is using the development server for production. Doing that is a VERY BAD IDEA.

Gabriel Hurley
A: 

You can ask django to serve the media files when used on the development server.

The standard way to do so is to add this in the urls.py

if DEBUG:

(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
    {'document_root': '/path/to/media'}),

PS: I personally still prefer to serve media from nginx even locally.

Lakshman Prasad