Support internationalized routes in API pages/find/?html_path view
See original GitHub issueIs your proposal related to a problem?
It doesn’t appear to work to find a page using the ?html_path
query param if it has a locale prefix. I found that the find_object
method in the pages api view set doesn’t seem to consider the locale prefix so that’s probably the reason. We’re using Wagtail as a headless CMS and the ability to query page data using the meta.html_url
we get from the /pages/
-endpoint would be very useful.
Describe the solution you’d like
We’d like to be able to simply query the pages using an html path that includes the locale prefix. Eg. /pages/find/?html_path=/sv/my-page/
.
I subclassed the Pages view set to implement this feature, but I think it belongs in wagtail core.
Describe alternatives you’ve considered
I also considered respecting the locale
query parameter to switch root page in the find_object
method. However, I think it is neater to use the locale prefix in the path, since that is what we get back from the API in meta.html_url
on the Page object.
Additional context
I can make a PR with the changes if you’d like to merge this change.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:5 (4 by maintainers)
Top GitHub Comments
Gave this a go and here’s what I’ve come up with:
Here’s an updated viewset that handles search for simple_translation/wagtail-localize which create separate trees, thus require searching in root page translation children.