[Answer]-Show picture in django

1👍

What version of django are you using?

in 1.4 you can do this in your template:

<img src="{{ STATIC_URL }}hi.jpg" />

or

<img src="../static/hi.jpg" />

and in your settings.py:

MEDIA_ROOT = '/Users/YOURUSERNAME/Desktop/YOURPROJECTNAME/static'
^^^ this just has to be the path to the static directory in your project ^^^

MEDIA_URL = '/static/'

STATIC_ROOT = ''

STATIC_URL = '/media/'

then in your urls.py:

if settings.DEBUG: urlpatterns += patterns('', (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), )
👤lciamp

0👍

This is what u need i guess:

<img src="{{ STATIC_URL }}img/11.jpeg" />

Leave a comment