0

这是画廊页面模型,到目前为止我们已经添加了 142 张图片,我们可以在其他页面中添加更多图片,但是在这个页面上,即使我删除了一张图片并尝试添加另一张图片,我也得到了400 Bad Request一个发布和Error while sending preview data.预览

class Gallery(Page):
    
    content_panels = Page.content_panels + [
        InlinePanel('media', label=_('Gallery Media'))
    ]


class GalleryMedia(ClusterableModel, Orderable):
    category = ParentalManyToManyField("gallery.GalleryCategory", blank=True)
    gallery = ParentalKey(
        "gallery.Gallery", on_delete=models.CASCADE, related_name="media", null=True
    )
    image = models.ForeignKey(
        "wagtailimages.Image", on_delete=models.CASCADE, related_name="+", null=True, blank=True, 
        help_text="The recommended sizes and dimensions for the images are:  350*200 / Aspect Ratio 7 : 4 - 350*700 / Aspect Ratio 1 : 2 - 350*500 / Aspect Ratio 7 : 10"
    )
    video_url = models.URLField(blank=True)
    video = models.ForeignKey(
        "wagtailvideos.Video",
        related_name="+",
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
    )
    show_large = models.BooleanField(default=False)
    show_on_homepage = models.BooleanField(default=False, verbose_name="Show on HomePage")

    panels = [
        ImageChooserPanel("image"),
        FieldPanel("video_url"),
        VideoChooserPanel("video"),
        FieldPanel("show_large"),
        FieldPanel("show_on_homepage"),
        MultiFieldPanel([FieldPanel("category", widget=CheckboxSelectMultiple),]),
    ]


class GalleryCategory(models.Model):
    name = models.CharField(max_length=50)

    panels = [
        FieldPanel("name"),
    ]
4

1 回答 1

1

您可能正在点击https://docs.djangoproject.com/en/3.2/ref/settings/#data-upload-max-number-fields。调整该设置和相关设置应该可以工作

于 2021-05-11T13:53:05.030 回答