Can someone help me with this issue: I have a Django porject,
in settings.py
MEDIA_ROOT = 'C:/Users/hl/workspace/beer/media'
MEDIA_URL = '/media/'
STATICFILES_DIRS = (
'C:/Users/hl/workspace/beer/media'
)
and in models.py
image1= models.ImageField(upload_to=settings.MEDIA_ROOT)
and in url.py
(r'^media/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.MEDIA_ROOT}),
in views
def allBeer(request):
beers=Beer.objects.all().order_by("name")
context={'beers': beers}
return render_to_response('AllBeers.html',context,context_instance=RequestContext(request))
and in html
{%for beer in beers %}
<p>
<a href="/beers/{{beer.slug}}/">
<img scr="{{beer.image1.url}}">{{beer}}
</a>
</p>
{% endfor%}
It has not problem to load images, but images wont show in html file. I have searched and read a lot from internet but I still couldn't figure out.
Can anyone tell me why?