Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot specify order for admin API page results when using for_explorer #11859

Open
maya413 opened this issue Apr 17, 2024 · 1 comment
Open
Labels

Comments

@maya413
Copy link

maya413 commented Apr 17, 2024

when i get sidebar pages use below url :
api/main/pages/?child_of=4&for_explorer=1&fields=parent&order=-id
response is : filtering by for_explorer without child_of is not supported

but when i get sidebar pages use below url :
api/main/pages/?child_of=4&for_explorer=1&fields=parent
response is fine,

@maya413 maya413 added status:Unconfirmed Issue, usually a bug, that has not yet been validated as a confirmed problem. type:Bug labels Apr 17, 2024
@maya413 maya413 changed the title i guss found a bug! don't be angry bird if not . i mabe found a bug! Apr 18, 2024
@gasman gasman changed the title i mabe found a bug! Cannot specify order for admin API page results when using for_explorer Apr 22, 2024
@gasman
Copy link
Collaborator

gasman commented Apr 22, 2024

Thanks for the report @maya413! I can confirm I'm seeing the same issue when testing against bakerydemo:

http://localhost:8000/admin/api/main/pages/?child_of=1&for_explorer=1&fields=parent returns results
http://localhost:8000/admin/api/main/pages/?child_of=1&for_explorer=1&fields=parent&order=id returns the error filtering by for_explorer without child_of is not supported

It looks like this is because the for_explorer filter relies on a _filtered_by_child_of attribute being set on the queryset, but applying an ordering replaces that queryset with a new one.

The admin API isn't really intended to be used outside of Wagtail's own code, but I'll accept this as a legitimate bug.

@gasman gasman removed the status:Unconfirmed Issue, usually a bug, that has not yet been validated as a confirmed problem. label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants