我正在使用它在我的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管理面板中显示所有图像...
答案 0 :(得分: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
答案 1 :(得分: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
图片的将不会显示...