我正在添加一组字段,可以由我的用户在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"
),
]
答案 0 :(得分:4)
根据http://docs.wagtail.io/en/stable/reference/contrib/settings.html#edit-handlers,您应该使用panels
,而不是content_panels
。
(Wagtail页面上使用的名称content_panels
来自于它影响"内容"标签的事实,而不是"推广"或&#34 ;设置"。对于设置和代码段模块,默认情况下没有标签 - 因此它只被称为panels
。)