I installed photologue correctly in my project (blog) and I can add images in admin panel, but how to display them on my main page?
How to add a gallery in photologue?
273 views Asked by meowz At
2
There are 2 answers
0
On
For one of my projects, I created a product model had a foreign key linked to a Gallery:
gallery = models.ForeignKey(Gallery, blank=True, related_name='gallery')
The issue in the template is that you cannot iterate over a Gallery or Photo from Photologue. I had to call product.gallery.photos.all() in order to iterate over the collection of images in my gallery.
To get the url of the image to link to the src of an <img> tag, you can just run (if you're iterating):
for image in product.gallery.photos.all():
{{ image.url }}
Hope this helps!
In the admin panel, you also need to: