I have a Wagtail site and I have a parent/child structure between a couple of page types:
class FrontPage(Page):
subpage_types = ["InnerPage"]
def get_next_page(self):
return self.get_children().live().first()
class InnerPage(Page):
parent_page_types = ["FrontPage"]
def get_next_page(self):
return self.get_next_siblings().live().first()
The Admin user can drag the InnerPage
s into their chosen order in the Wagtail Admin, which is great. FrontPage.get_children()
then fetches the inner pages in that order, and the get_next_page()
methods return the next pages in the same order.
I'd like to write tests to check that the get_next_page()
methods do return the correct page. But I can't work out how to assign an order to pages when creating them for tests. I can see that when doing the SQL queries Wagtail orders by wagtailcore_page.path
, but I'm not sure how to affect this when programmatically creating InnerPage
objects.