1

我正在添加一组可由我的用户在 Wagtail Admin 中填写的字段。一切正常,但我想在面板组中组织设置,但它不起作用。有人可以在下面查看我的代码,看看我这样做是否正确吗?

...
from wagtail.contrib.settings.models import BaseSetting, register_setting
from wagtail.wagtailadmin.edit_handlers import MultiFieldPanel, FieldPanel


@register_setting
class SiteSettings(BaseSetting):
    facebook = models.URLField(blank=True, help_text='Your Facebook page URL')
    instagram = models.CharField(max_length=255, blank=True, help_text='Your Instagram username, without the @')
    youtube = models.URLField(blank=True, help_text='Your YouTube channel or user account URL')
    company_name = models.CharField(blank=True, max_length=250, help_text='Enter your company name how you would like it to appear on the site')

    content_panels = [
        MultiFieldPanel(
            [
                FieldPanel('facebook'),
                FieldPanel('instagram'),
                FieldPanel('youtube'),
            ],
            heading="Social Media Profiles",
            classname="collapsible collapsed"
        ),
        MultiFieldPanel(
            [
                FieldPanel('company_name'),
            ],
            heading="Company Info",
            classname="collapsible collapsed"
        ),
    ]
4

1 回答 1

4

根据http://docs.wagtail.io/en/stable/reference/contrib/settings.html#edit-handlers,您应该使用panels,而不是content_panels

content_panelsWagtail 页面上使用的名称来自于它影响“内容”选项卡,而不是“推广”或“设置”。对于设置和片段模块,默认情况下没有选项卡 - 所以它很简单称为panels。)

于 2016-07-05T15:39:44.470 回答