-1

我正在使用它在我的 Django 管理面板中显示图像,但是有什么方法可以显示多个图像:

def product_Image(self):
    """Method to return store image for admin panel"""

    return '<img src="/images/%s" height="150" width="150"/>' % self.image_paths
product_Image.allow_tags = True

但是如果self.image_paths包含图像路径列表:["full/1182_Garishma1.jpg","full/K-Yukta-A.jpg"] 那么我如何在 django 管理面板中显示所有图像...

4

2 回答 2

1

尝试这个 :

def product_Image(self):
    """Method to return store image for admin panel"""

    images = ''
    for image_path in self.image_paths:
        images += '<img src="/images/%s" height="150" width="150"/>' % image_path            
    return images
product_Image.allow_tags = True

没有product_Image.allow_tags = True图像将不会显示...

于 2013-06-07T14:36:36.583 回答
1

你不能先循环路径吗?

def product_Image(self):
    """Method to return store image for admin panel"""

    images = ''
    for image_path in self.image_paths:
        images += '<img src="/images/%s" height="150" width="150"/>' % image_path

    return images
于 2013-06-07T13:58:13.347 回答