python - showing image in templates using django -
i new django. project folder contain media folder. contain images.
how can display images in template of app?
path : mysite/media/blog/templates/blog/details.html
details.html
{{<img src="media/image_2.jpg">}}
but not display anything..
you should set-up static folder , configure media files.
the full reference: https://docs.djangoproject.com/en/dev/howto/static-files/ , https://docs.djangoproject.com/en/1.4/howto/static-files/.
however should use (once configured static files) :
<img src="{% static "media/myexample.jpg" %}"/>
edit: before using static
tag, must load specific tags incluing on top of template code: {% load staticfiles %}
: referring static files in templates
Comments
Post a Comment