1👍
✅
You have to use 2 forloop for displaying images in manytomany table.
{% for i in slider %}
<li>
{% for im in i.image.all %}
<img src="{{im.image.url}}" alt="{{im.name}}"/>
{% endfor %}
<h2>{{i.title}}</h2>
<p>{{i.text}}, {{i.image_url}}</p>
</li>
{% endfor %}
0👍
Article.image
is a ManyToMany field. Which image You want to display? First?
<img src="{{i.image.all.0.image.url}}" alt="{{i.title}}"/>
All?
{% for im in i.image.all %}
<img src="{{im.image.url}}" alt="{{im.name}}"/>
{% endfor %}
- Django exception handler for the default-brench in try-except block
- How can I filter queries in view.py and render them into the template?
- How do I get Django multi-argument url tags working?
- Django Rest Framework Test Class Error
- 'unicode' object has no attribute 'has_header'
Source:stackexchange.com