I just resolved the issue. the line MEDIA_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)),'multimedia')
was the problem and pointing to the wrong path. so the photos were stored in "/home/.../cs142/multimedia/photos/xyz.jpg" but due to the MEDIA_ROOT problem it pointed to "/home/..../assignment3/cs142/ multimedia/photos/xyz.jpg" here assignment3 is a directory at the same level as multimedia. In any case sorry if I wasted anybody's time. On Nov 4, 12:35 am, Abhas <abhasfor...@gmail.com> wrote: > Hi everyone, > > I am having trouble displaying images stored on my laptop using Django > templates.To highlight the problem I am using a view called test which > renders a template called test.html. code for them is as follows: > > def test(request): > return > render_to_response('test.html',context_instance=RequestContext(request,proc > essors=[custom_proc])) > > def custom_proc(request): > return {'MEDIA_URL':settings.MEDIA_URL} > > "test.html" > > <html> > <head> this is a test page </head> > > <body> > <img src="{{MEDIA_URL}}photos/hilton1.jpg" alt="Paris Hilton" /> > </body> > </html> > > on rendering this page, the image does not get displayed instead > displaying the text associated with "alt" in the img tag.On viewing > page source,it shows src="/multimedia/photos/hilton1.jpg" which is the > correct location of the image file. > > My settings are as follows: > MEDIA_ROOT = > os.path.join(os.path.abspath(os.path.dirname(__file__)),'multimedia') > MEDIA_URL = '/multimedia/' > ADMIN_MEDIA_PREFIX = '/media/' > > finally here are the settings in "urls.py" > if settings.DEBUG: > from django.views.static import serve > if settings.MEDIA_URL.startswith('/'): > _media_url=settings.MEDIA_URL[1:] > urlpatterns+=patterns('',(r'^%s(?P<path>.*)$' % _media_url,serve, > {'document_root':settings.MEDIA_ROOT,})) > del(_media_url,serve) > > I have tried searching the net without any resolution to this > problem.Any help would be greatly appreciated. > > Thanks > > Abhas -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.