Skip to content
Advertisement

Detail view context

how can i get all images of item into context i tried {% for image in item.images.all %} in template but it doesn’t work. i dunno how to filter it , ty for ur answer

models

JavaScript

views

JavaScript

Advertisement

Answer

You’re pretty close. In your template tag {% for image in item.images.all %}, image refers to an instance of your ItemImage model. You need to reference the ImageField within that model, which you’ve named images. So, instead of src="{{ image.url }}" use src="{{ image.images.url }}"

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement