question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Filter PageChooserPanel queryset

See original GitHub issue

It would be great if you could filter Pages on PageChooserPanel using a queryset.

Something like:

PageChooserPanel('link_page', queryset=EventPage.objects.live().descendant_of(events_index)),

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:2
  • Comments:24 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
Sam-Costigancommented, Mar 26, 2019

Not quite the same as specifying the QuerySet per PageChooserPanel, but this issue is one of the top results for filtering the PageChooserPanel through any means so I thought it would be good to link to this relevant wagtail hook: https://docs.wagtail.io/en/v1.11.1/reference/hooks.html#construct-page-chooser-queryset

That hook might then be used like:

@hooks.register('construct_page_chooser_queryset')
def limit_page_chooser_to_site_specific_pages(pages, request):
    try:
        return pages.in_site(request.site)
    except Exception as e:
        # couldn't filter by site so return untouched pages queryset
        return pages

In order to achieve the site-limited query sets mentioned by @cnk.

1reaction
gasmancommented, Nov 30, 2022

@brylie Overriding get_object_list is indeed the way to go.

Read more comments on GitHub >

github_iconTop Results From Across the Web

wagtail - Filter the pages available to link to another page
I've been trying to find a way to filter a the values in a chooser (PageChooserPanel). I'm building a story site where authors...
Read more >
Developers - Filter PageChooserPanel queryset - - Bountysource
Filter PageChooserPanel queryset ... It would be great if you could filter Pages on PageChooserPanel using a queryset. Something like: PageChooserPanel('link_page ...
Read more >
Filter Reference — django-filter 22.1 documentation
An optional argument that tells the filter how to handle the queryset. It can accept either a callable or the name of a...
Read more >
Available panel types — Wagtail 2.9 documentation
PageChooserPanel takes one required argument, the field name. Optionally, specifying a page type (in the form of an "appname.modelname" string) will filter ......
Read more >
How To Prevent Duplicates When Using Modelchoicefilter In ...
It would be great if you could filter Pages on PageChooserPanel using a queryset. in Django admin which is Django admin's equivalent of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found