Skip to content Skip to sidebar Skip to footer

Use Django Template Tags In Img Src

I am trying to use the Django template tags to bring up specific images that correlate with each choice, however it does not seem to work, just return a broken image. Here is my re

Solution 1:

Just set a variable on the context containing the path to the file in question. You can reference variables in the static template tag (here named special_image_path):

<img class="img-responsive" src="{% static special_image_path %}"/>

See the second example here in the Django docs

Post a Comment for "Use Django Template Tags In Img Src"