Reputation: 217
I'm trying to vary images based on a variable - id in the Django template.
<img href="'https://res.cloudinary.com/.../image/'|add:{{ object.id }}|add:'.png'" class="mx-auto" width="100px" alt="No Image"/>
object.id is passed into the template from a Queryset object (i.e. object).
Page load, but image does not show up and goes to alt="No Image".
Upvotes: 1
Views: 158
Reputation: 476768
Your |add:
etc are not interpreted by the Django template engine, since these are not between curly brackets ({{ … }}
), nor templat tag brackets ({% … %}
). THis is also not necessary, you can create the URL with:
<img src="https://res.cloudinary.com/.../image/{{ object.id }}.png">
Upvotes: 1