Opened 6 years ago

Last modified 7 days ago

#15143 new New feature

Document how to set the language for the test client

Reported by: claudep Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: poswald Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


I suggest to add a note in the documentation about how to set the language for the test client.

Without the LocaleMiddleware, it's possible to set it with the activate/deactivate functions from django.utils.translation.

When LocaleMiddleware is activated, another method has to be used, otherwise the settings.LANGUAGE_CODE is always used. I've been able to set the language by passing HTTP_ACCEPT_LANGUAGE='de' to the get/post method, or by loading a cookie (client.cookies.load({settings.LANGUAGE_COOKIE_NAME:'de'})).

Change History (6)

comment:1 Changed 6 years ago by ramiro

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

BTW, the activate/deactivate functions from django.utils.translation aren't documented either.

comment:2 Changed 5 years ago by poswald

  • Cc poswald added

comment:3 Changed 5 years ago by lrekucki

  • Severity set to Normal
  • Type set to New feature

comment:4 Changed 5 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:5 Changed 5 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:6 Changed 7 days ago by timgraham

  • Easy pickings set
  • Summary changed from Add precisions about setting the language for the test client to Document how to set the language for the test client
  • Version changed from 1.2 to master

Looks like this could go in the test client documentation at docs/topics/testing/tools.txt.

Note: See TracTickets for help on using tickets.
Back to Top