5

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?

ladrua
  • 415
  • 5
  • 16

2 Answers2

1

Ok, as of now. It doesn't seem that this is possible. But it does seem that it respects django models default ordering. https://docs.djangoproject.com/en/2.1/ref/models/options/#ordering

ladrua
  • 415
  • 5
  • 16
  • 2
    No it doesn't. https://docs.wagtail.io/en/stable/topics/pages.html#page-queryset-ordering – Soitje Oct 22 '21 at 10:04
1

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
monkut
  • 42,176
  • 24
  • 124
  • 155