#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
--------------------------------------+------------------------------------

Comment (by Tomer Chachamu):

 Here are some passing tests showing how the view will behave when you have
 set `next` correctly.

 {{{#!python
 @override_settings(
     USE_I18N=True,
     LANGUAGES=[
         ('en', 'English'),
         ('fr', 'French'),
         ('de', 'German'),
     ],
     MIDDLEWARE=[
         'django.contrib.sessions.middleware.SessionMiddleware',
         'django.contrib.auth.middleware.AuthenticationMiddleware',
         'django.middleware.locale.LocaleMiddleware',
         'django.middleware.common.CommonMiddleware',
     ],
     ROOT_URLCONF='i18n.i18n_unprefixed_urls',
     LANGUAGE_CODE='en',
 )
 class UnprefixedI18nSetLang(TestCase):
     def test_en2fr(self):
         self.client.post('/i18n/setlang/', data={'language': 'en'})
         response = self.client.post(
             '/i18n/setlang/',
             data={'language': 'fr', 'next': '/admin/'},
             follow=True,
         )
         self.assertEqual(
             response.redirect_chain,
             [('/fr/admin/', 302), ('/fr/admin/login/?next=/fr/admin/',
 302)]
         )

     def test_fr2en(self):
         self.client.post('/i18n/setlang/', data={'language': 'fr'})
         response = self.client.post(
             '/i18n/setlang/',
             data={'language': 'en', 'next': '/admin/'},
             follow=True,
         )
         self.assertEqual(
             response.redirect_chain,
             [('/admin/', 302), ('/admin/login/?next=/admin/', 302)]
             )

     def test_fr2de(self):
         self.client.post('/i18n/setlang/', data={'language': 'fr'})
         response = self.client.post(
             '/i18n/setlang/',
             data={'language': 'de', 'next': '/admin/'},
             follow=True,
         )
         self.assertEqual(
             response.redirect_chain,
             [('/de/admin/', 302), ('/de/admin/login/?next=/de/admin/',
 302)]
             )
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28567#comment:6>
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.1d6a1fd7227bb5265dac2df83e51e712%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to