如何在photologue中添加图库?

时间:2015-04-22 06:23:13

标签: python django photologue

我在我的项目(博客)中正确安装了photologue,我可以在管理面板中添加图片,但是如何在我的主页上显示它们?

2 个答案:

答案 0 :(得分:0)

在管理面板中,您还需要:

  1. 创建图库。
  2. 选择哪些照片属于哪些画廊。

答案 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!