Django - Redirecting A User To A Specific View After Get To A Separate View, Changing Language Settings
I have a site with that offers 2 language choices - English & Japanese. To change between the languages, A user clicks a button taking them to a view which changes the setting
Solution 1:
I found a workaround to the above problem.
Fixed by adding the {{ request.resolver_match.url_name }}
to the a tag's query param and then called reverse
on that query param within the view:
Link:
<a href="{% url 'language' 'en' %}?q={{ request.path }}" class="lang-choice btn btn-primary">English</a>
to:
<a href="{% url 'language' 'en' %}?q={{ request.resolver_match.url_name }}" class="lang-choice btn btn-primary">English</a>
The view is then refactored:
response = redirect(redirect_page)
To:
response = redirect(reverse(redirect_url_name))
Post a Comment for "Django - Redirecting A User To A Specific View After Get To A Separate View, Changing Language Settings"