4👍
✅
With the code you are using, you don’t need to write your own views. The form will make a POST request to /i18n/setlang/, with the language code and (optional) the redirect-to (next) page as parameters.
The django view does the following (from the django documentation)
Django looks for a next parameter in the POST data.
– If that doesn’t exist, or is empty, Django tries the URL in the Referrer header.
– If that’s empty — say, if a user’s browser suppresses that header — then the user will be – redirected to / (the site root) as a fallback.
So in essence, the user will be redirected after submitting the form, and the django view will set the language for that user according to what was submitted.
Hope this helps,
Hoff
👤Hoff
Source:stackexchange.com