我在我的项目(博客)中正确安装了photologue,我可以在管理面板中添加图片,但是如何在我的主页上显示它们?
答案 0 :(得分:0)
在管理面板中,您还需要:
答案 1 :(得分:0)
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!