【发布时间】:2018-05-02 06:45:16
【问题描述】:
如何在 wagtail 中选择多个页面而不是单个页面?
在我的代码中,我使用了 link_page,它只选择一页
class Collections(models.Model):
heading = TextField(blank=True,)
description = RichTextField(blank=True,)
SelectResources = SortedManyToManyField(SelectResource)
link_page = models.ForeignKey(
'wagtailcore.Page',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
panels = [
FieldPanel('heading', classname="title"),
FieldPanel('description', classname="full"),
FieldPanel('link_page'),
]
class Meta:
abstract = True
class HomeCollections(Orderable, Collections):
page = ParentalKey('Home', related_name='collections')
集合作为内联面板添加到主页
class Home(AbstractForm):
content_panels = AbstractForm.content_panels +[
InlinePanel('collections', label="collections"),
]
【问题讨论】:
-
这是除此问题之外的评论,请尽量不要使用 Collections 作为您的模型名称。 Python 标准库中有一个名为 Collections 的模块(docs.python.org/3.6/library/collections.html 和 docs.python.org/2.7/library/Collections.html),可能会让其他人感到困惑。问候!
标签: django python-3.x django-models wagtail