Thank you. That solves my problem. I had mistakenly assumed that as the introduction of django.contrib.staticfiles made django.views.static.serve unnecessary for static files, it also had the same consequence for media files. Thanks again. Rodney
On Sep 20, 6:34 pm, Praveen Krishna R <[email protected]> wrote: > *Have you done something like this in your project urls.py* > * > * > * > urlpatterns += patterns('', > * > (r'^site_media/(?P<path>.*)$', > 'django.views.static.serve',{'document_root': settings.MEDIA_ROOT}), > ) > So that you can enable serving the media from the development server ?! > *my MEDIA_URL = '/site_media/'* > > And html from the templates > *<li> <img src="{{ MEDIA_URL }}{{ photo.photo }}" ></li>* > > > > > > On Tue, Sep 20, 2011 at 7:43 AM, Rodney Topor <[email protected]> wrote: > > I've written a small project to upload and view images using a recent > > development version of Django. In settings.py, I've defined > > MEDIA_ROOT = join(PATH, 'media') # the full path to the media > > subdirectory of my project directory > > MEDIA_URL = '/media/' > > I've created subdirectories /media/images in my project directory. > > I've defined my model with an ImageField(upload_to='images'), defined > > a form with enctype="multipart/form-data/", etc. > > When I create a new object with a selected image, the image is > > correctly uploaded to /media/images/. The HTML page intended to > > display the image correctly (?) uses the following HTML element: > > <img alt="images/foo.jpg" src="/media/images/foo.jpg" height="40" > > width="100" /> > > The development server displays a message of the form: > > [20/Sep/2011 14:35:04] "GET /media/images/foo.jpg HTTP/1.1" 404 2218 > > I.e., the image is not found and the rendered page contains only a > > query where the image should be displayed. > > So the images are being uploaded correctly, the generated HTML > > contains <img> elements that refer to the correct locations of the > > images, but they are not being displayed. The image and its > > containing directories are all world-readable. > > So can someone please explain what else I have to do to make this > > work? Many thanks. > > Rodney > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- > Thanks and Regards, > *Praveen Krishna R* -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

