问题描述
W
我的模型代码:
class HomePage(Page):
images = models.ImagesField(max_count = 20) // How to do it right?
content_panels = Page.content_panels + [
ImagesChooserPanel('images'),]
请帮助!
解决方法
由流域解决
images = StreamField([
('image',ImageChooserBlock()),])
,
(可悲)你不能这样
images = models.ImagesField(max_count = 20)
但是您可以通过多种方式将多个图像关联到同一模型
- 使用
image1 = models.ImagesField(upload_tp='somewhere') image2 = models.ImagesField(upload_tp='somewhere')
- 使用外键将第二个关联模型与另一个模型关联,并使用第一种方式