Wagtail admin - default ordering of child pages

Viewed 2331

In the admin area I have to activate the "Enable ordering of child pages" every time. Is there a way to set this as a permanent option? The main problem is that the listing in the child pages view changes depending on if this is activated or not(if you have changed the ordering), which might be a bit confusing for some.

Potentially one could change the default ordering of the children list to match the manually ordered list somehow?

2 Answers

Setting the Meta.ordering on the ChildPage model didn't work for me, but overriding the Parent Page's get_children() method by returning the ordered QuerySet resolved the child page order issue.

class MyRootPage(Page):
    description = models.CharField(max_length=255, blank=True)

    content_panels = Page.content_panels + [FieldPanel("description", classname="full")]

    def get_children(self):
        qs = super().get_children()
        qs = qs.order_by('-last_published_at')
        return qs
Related