ivan.zd
ivan.zd

Reputation: 734

Django set_language function redirects to site root although next parameter is defined

I am using django.views.i18n.set_language() redirect view and HTML form where user can choose language. I am doing everything as it's described in Django documentation for i18n translation . The only difference that I made is that within HTML form I changed value of next parameter from {{redirect_to}} to {{request.get_full_path}}

Anyway, It worked completely fine while I was testing it locally. I could select different language and it would reload current page but with different language.

Now I put application on VPS where I use Gunicorn as application server and Nginx as web server. Now when I select different language it still changes it but it always redirect me to to home page / (site root).

I have no idea why is that happening now and how to change it. I want that he reloads the same page again instead of redirecting me to the / always. Anyway, at translation still works fine.

Thank you for your replys

Kind regards

Upvotes: 2

Views: 802

Answers (1)

Kevin Brown-Silva
Kevin Brown-Silva

Reputation: 41699

Wander Nauta answered it in the comments

Are you sure request.get_full_path is available in the template?

You need to add django.core.context_processors.request in your template context processors settings, which is not there by default.

Upvotes: 2

Related Questions