如何更改父页面?

How to change the parent page?

我在管理单视图中有文章页面的自定义视图和表单。在表格中,我有 HTML5 select 用于更改父项(部分)。如何在管理编辑视图中更改父页面?我尝试使用已编辑的 python wagtail.admin.views.pages.edit:

#wagtail code 
revision = page.save_revision(
    user=request.user,
    submitted_for_moderation=is_submitting,
)
#next I try to place my code
new_parent_page_id = request.POST.get('parent_page_id')
if int(new_parent_page_id) != parent.id:
    parent = SectionPage.objects.get(id=new_parent_page_id)
    page.move(parent, pos='last-child')
    page.save()

它不起作用

wagtail 版本 2.4

new_parent_page_id = request.POST.get('parent_page_id')
if int(new_parent_page_id) != parent.id:
    parent = SectionPage.objects.get(id=new_parent_page_id)
    page.move(parent, pos='last-child')
    page = page.specific_class.objects.get(pk=page.pk)

为清楚起见,我能够使用以下代码使其工作:

parent = Page.objects.find(...)

child = Page.objects.find(...)

child.move(parent, pos="last-child")