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

Using wagtail headless API #165

Open
onno-timmerman opened this issue Jul 31, 2019 · 2 comments
Open

Using wagtail headless API #165

onno-timmerman opened this issue Jul 31, 2019 · 2 comments

Comments

@onno-timmerman
Copy link

When I go to http://localhost:8000/api/v2/pages I only get results from one language. There is no mention in the docs how to handle the API with wagtail trans. How do you switch the language when using wagtail api?

@mikedingjan
Copy link
Member

Hi @onno-timmerman ,

In the basics watailtrans (if configured right) is only a tool which makes it easier for site administrators to have multiple languages. Each language will have it's own page tree, which means all "homepages" are a child of the "root_page". so they all have their own id and you should be able to query the right pages as children of the site "homepage" TranslatableSiteRoot.. During development we didn't do anything for the API part of Wagtail since they're seperate page trees.

Having said that I must honestly say I don't know how the API handles this, but what I can say is that the TranslatableSiteRoot will select the right HomePage according to request.LANGUAGE_CODE kinda like django's LocaleMiddelware does.

Maybe you can share a bit more about your setup so helping you getting the right pages via API or determine where the problem lies would be a bit easier?

@onno-timmerman
Copy link
Author

I solved the issue by first query for the language what the homepage is by passing slug=lang then fetching all the childs of it. I think that is correct way to handle it. I just expected that in /pages all the items would be available and not from one language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants