[4.1.x] Fixed #34180 -- Added note about resetting language in test tear-downs.
Co-authored-by: Faris Naimi <farisfaris66@gmail.com> Backport of 40217d1a82b0c16cddba377325d12b2c253f402a from main
This commit is contained in:
parent
26b7a25632
commit
f586c12f01
1
AUTHORS
1
AUTHORS
@ -326,6 +326,7 @@ answer newbie questions, and generally made Django that much better:
|
|||||||
Florian Apolloner <florian@apolloner.eu>
|
Florian Apolloner <florian@apolloner.eu>
|
||||||
Florian Demmer <fdemmer@gmail.com>
|
Florian Demmer <fdemmer@gmail.com>
|
||||||
Florian Moussous <florian.moussous@gmail.com>
|
Florian Moussous <florian.moussous@gmail.com>
|
||||||
|
fnaimi66 <https://github.com/fnaimi66>
|
||||||
Fran Hrženjak <fran.hrzenjak@gmail.com>
|
Fran Hrženjak <fran.hrzenjak@gmail.com>
|
||||||
Francisco Albarran Cristobal <pahko.xd@gmail.com>
|
Francisco Albarran Cristobal <pahko.xd@gmail.com>
|
||||||
Francisco Couzo <franciscouzo@gmail.com>
|
Francisco Couzo <franciscouzo@gmail.com>
|
||||||
|
@ -638,6 +638,14 @@ or by including the ``Accept-Language`` HTTP header in the request::
|
|||||||
response = self.client.get('/', HTTP_ACCEPT_LANGUAGE='fr')
|
response = self.client.get('/', HTTP_ACCEPT_LANGUAGE='fr')
|
||||||
self.assertEqual(response.content, b"Bienvenue sur mon site.")
|
self.assertEqual(response.content, b"Bienvenue sur mon site.")
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
When using these methods, ensure to reset the active language at the end of
|
||||||
|
each test::
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
translation.activate(settings.LANGUAGE_CODE)
|
||||||
|
|
||||||
More details are in :ref:`how-django-discovers-language-preference`.
|
More details are in :ref:`how-django-discovers-language-preference`.
|
||||||
|
|
||||||
If the middleware isn't enabled, the active language may be set using
|
If the middleware isn't enabled, the active language may be set using
|
||||||
|
Loading…
x
Reference in New Issue
Block a user