I have a Model object containing images field. Now I want to get the images in template by a sequence like one image floating left and another one floating right order from last entry.
models.py
# models.py
class Image(models.Model):
icon = models.ImageField(upload_to='static/img')
views.py
# views.py
def index():
image = Image.objects.all()
return render(request, 'index.html', {'images': image})
index.html
{% for image in images %}
<div class="item">
<div class="float-left">
{{ image }}
</div>
<div class="float-right">
This is Image Description.
</div>
</div>
<div class="item">
<div class="float-left">
This is Image Description.
</div>
<div class="float-right">
{{ image }}
</div>
</div>
{% endfor %}
Assume all imports are ok.
HTML Look: