在 Django Wagtail BaseSettings 中添加一个 MultiFieldPanel
Add a MultiFieldPanel in Django Wagtail BaseSettings
我正在添加一组可以由我的用户在 Wagtail 管理中填写的字段。一切正常,但我想在面板组中组织设置,但它不起作用。有人可以查看我下面的代码,看看我这样做是否正确吗?
...
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"
),
]
根据 http://docs.wagtail.io/en/stable/reference/contrib/settings.html#edit-handlers,您应该使用 panels
,而不是 content_panels
。
(在 Wagtail 页面上使用的名称 content_panels
来自于它影响 "Content" 选项卡的事实,而不是 "Promote" 或 "Settings"。对于settings 和 snippets 模块,默认情况下没有选项卡 - 所以它被简单地称为 panels
。)
我正在添加一组可以由我的用户在 Wagtail 管理中填写的字段。一切正常,但我想在面板组中组织设置,但它不起作用。有人可以查看我下面的代码,看看我这样做是否正确吗?
...
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"
),
]
根据 http://docs.wagtail.io/en/stable/reference/contrib/settings.html#edit-handlers,您应该使用 panels
,而不是 content_panels
。
(在 Wagtail 页面上使用的名称 content_panels
来自于它影响 "Content" 选项卡的事实,而不是 "Promote" 或 "Settings"。对于settings 和 snippets 模块,默认情况下没有选项卡 - 所以它被简单地称为 panels
。)