Python 3.x 如何在Wagtail中为页面模型编写自定义视图?
我在Python 3.x 如何在Wagtail中为页面模型编写自定义视图?,python-3.x,django,wagtail,Python 3.x,Django,Wagtail,我在models.py中有一个页面对象,如下所示: class PostPage(Page): template = 'Blog/post_page.html' # Database fields body = RichTextField() main_image = models.ForeignKey( 'wagtailimages.Image', null=True, blank=True, on
models.py中有一个页面对象,如下所示:
class PostPage(Page):
template = 'Blog/post_page.html'
# Database fields
body = RichTextField()
main_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
promote_panels = [
InlinePanel('related_links', label="Related links"),
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
]
....
class PostPageView(PermissionMixin, PostPage):
required_permission = 'special_user'
我想在views.py
中将此页面与另一个视图混合使用,如下所示:
class PostPage(Page):
template = 'Blog/post_page.html'
# Database fields
body = RichTextField()
main_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
promote_panels = [
InlinePanel('related_links', label="Related links"),
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
]
....
class PostPageView(PermissionMixin, PostPage):
required_permission = 'special_user'
或django角色权限的某些视图
或通用视图
我该怎么做?在将它们混合在一起之后,我如何解释上下文处理器使用PostPage view
而不是PostPage
另一个问题是如何设置页面对象的视图?我在Wagtail admin中找到了CreateView
和EditView
,但找不到DetailView
的任何内容