Reputation: 61
I have custom view and form for article page in admin single view. In form I have HTML5 select for change parent (section). How to change the parent page in admin edit view? I try ty use edited 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()
and it doesn't work
wagtail version 2.4
Upvotes: 2
Views: 937
Reputation: 1862
For clarity, I was able to get this to work with the following code:
parent = Page.objects.find(...)
child = Page.objects.find(...)
child.move(parent, pos="last-child")
Upvotes: 0
Reputation: 61
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)
Upvotes: 3