#28567: Unclear documentation for 'next' parameter of set_language view
--------------------------------------+------------------------------------
     Reporter:  George Tantiras       |                    Owner:  (none)
         Type:  Bug                   |                   Status:  new
    Component:  Internationalization  |                  Version:  1.11
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  1
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Changes (by Tomer Chachamu):

 * owner:  Tomer Chachamu => (none)
 * needs_docs:  0 => 1
 * status:  assigned => new
 * stage:  Unreviewed => Accepted


Comment:

 Thanks for that test, it really clarified it.

 In the HTML in the documentation you mentioned, it mentions the
 `redirect_to` context variable, but doesn't really explain what to set it
 to. In your case, it is empty, so the `set_language` view has started
 looking at the `HTTP_REFERRER` as shown in your tests.

 You need to set `redirect_to` to the current page URL, without the
 language prefix. For example, you could add this context processor to your
 settings:

 {{{#!python
 from django.urls import translate_url

 def redirect_path_context_processor(request):
     return {'language_select_redirect_to': translate_url(request.path,
 settings.LANGUAGE_CODE)}
 }}}

 The `set_language` view will then translate the URL again to the user's
 selected language.

 Also, if you *do* use `prefix_default_language=True`, then the URL for the
 set_language view should also be prefixed. I don't think this is
 documented anywhere.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28567#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.01a1a47d1a41340df2ecb6a6ec0bf422%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to