How to get all pages awaiting moderation in Wagtail

I'm trying to find a way to query all pages that are currently awaiting moderation.

I tried PageRevision.objects.filter(submitted_for_moderation=True).values('page_id'), but it seems to return only a few of them, I don't understand why.

If i can get all pages in moderation, then i will be able to get what I really want : all pages awaiting moderation for the user currently logged in.

Thanks a lot.

The submitted_for_moderation field is only used by the legacy moderation system that was deprecated in Wagtail 2.10 - pages submitted for moderation since then will use the Workflow system.

The equivalent to your query would be:

PageRevision.objects.filter(task_states__status='in_progress').values('page_id')

From Wagtail 4.0 onward PageRevision was replaced with a Revision model that covers snippet models too, so this will become:

Revision.page_revisions.filter(task_states__status='in_progress').values('object_id')

I don't know what version of Wagtail you are using but from the code provided, it looks like you are using the legacy moderation functionality. Please note that that is deprecated and will be removed completely in 2024. If you can upgrade, then the list of pages in moderation (aka in a workflow) will be automatically added to the dashboard for your users. (If you upgrade step by step, the system should automatically create a simple workflow that mimics the older moderation system.)

enter image description here

Back to Top