[Fixed]-Python / Django – creating a photo gallery – get pics' names instead of pics themself

1👍

To render a ImageField into template, you need:

<img src="{{ cup.photo }}" />

0👍

Well, everything was absolutely easy. You have to wrap with the for-loop not only the <img src="{{ cup.photo.url }}" />, but the divs’ as well. See below:

<div class="container-float">
    <div class="row">
        {% for cup in context_cups %}
        <div id="image-{{cup.id}}" class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
            <img src="{{ cup.photo.url }}" />
        </div>
        {% endfor %}
     </div>
</div>

Leave a comment