Opened 6 years ago

Closed 12 days ago

Last modified 12 days ago

#15143 closed New feature (fixed)

Document how to set the language for the test client

Reported by: Claude Paroz Owned by: Michael Scott
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: Paul Oswald Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

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 (12)

comment:1 Changed 6 years ago by Ramiro Morales

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

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

comment:2 Changed 6 years ago by Paul Oswald

Cc: Paul Oswald added

comment:3 Changed 5 years ago by Łukasz Rekucki

Severity: Normal
Type: New feature

comment:4 Changed 5 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 Changed 5 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:6 Changed 5 weeks ago by Tim Graham

Easy pickings: set
Summary: Add precisions about setting the language for the test clientDocument how to set the language for the test client
Version: 1.2master

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

comment:7 Changed 4 weeks ago by Michael Scott

Owner: changed from nobody to Michael Scott
Status: newassigned

I'm interested in contributing to Django and have been advised to start with some of the 'easy pickings' tasks, so I'll try picking up this issue to get started.

comment:8 Changed 2 weeks ago by Michael Scott

I've made the proposed changes to the testing tools topic documentation and pushed it to the branch https://github.com/mscott250/django/tree/ticket_15143 . I think the text looks suitable and I've included examples of the different ways to set the language.

I've created a pull request for the branch as the contributing docs say to do, it's available here https://github.com/django/django/pull/7233 . Please let me know if you think the text can be improved in any way or if there is anything else I need to do for this contribution.

Cheers,
Michael

comment:9 Changed 2 weeks ago by Simon Charette

Has patch: set
Patch needs improvement: set

comment:10 Changed 2 weeks ago by Michael Scott

Patch needs improvement: unset

Thanks for the feedback Simon, I've addressed all the items you mentioned and after fighting with Git a little bit I've created another pull request here https://github.com/django/django/pull/7238 .

Please let me know if there's any further improvements I can make to it or if there's anything else to do for this.

comment:11 Changed 12 days ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 3c447b10:

Fixed #15143 -- Doc'd how to set the language for the test client.

comment:12 Changed 12 days ago by Tim Graham <timograham@…>

In 416004c:

[1.10.x] Fixed #15143 -- Doc'd how to set the language for the test client.

Backport of 3c447b108ac70757001171f7a4791f493880bf5b from master

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