-
Notifications
You must be signed in to change notification settings - Fork 144
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
Move the i18n/ url outside of the i18n_patterns function as per the Django documentation #10754
Move the i18n/ url outside of the i18n_patterns function as per the Django documentation #10754
Conversation
Update master with latest in dev/7.6.x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jkemper-pca. Verified this fix works.
I retargeted your PR to dev/7.6.x, since master isn't a branch we use for development. (We should probably delete it.)
Since this is a change that requires user action (for existing projects), could you update 7.6.0.md and make these changes?
- add a changelog
- add an upgrade instruction (probably inserting a step after "In settings.py" so that it becomes "In urls.py")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks for the update!
Putting the code
path("i18n/", include("django.conf.urls.i18n"))
within thei18n_patterns(*urlpatterns)
causes issues when the app tries to switch languages. Setting up the urls this way is specifically warned against in the Django documentation.Types of changes
Description of Change
The "i18n/" url has been moved outside of the
i18n_patterns()
function by removing it from the urls.py in arches file (because all urls there get passed to thei18n_patterns()
function and is added instead in the project's urls.py file after the rest of the urls are passed to the function.Issues Solved
When trying to switch languages using the top-right language switcher, the behaviour was inconsistent and often reloaded the page but did not switch the language.
One way that I've found this happens is:
With this code change, the language will continue to swap correctly
Checklist
Ticket Background
Further comments
There might be other ways to changing the code around to take the i18n path out of the i18n_patterns so if this PR is just used to prompt looking into the issue that's fine with me.
If this change is merged, the documentation will also need to be updated slightly because the code in urls.py is used in a snippet on the Localizing Arches page