如何在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"),
]
答案 0 :(得分:0)
您可以使用StreamField创建PageChooserBlock。像这样:
pages = StreamField([
('page', blocks.PageChooserBlock())
])