#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: | dev |
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 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 14 years ago
Cc: | added |
---|
comment:3 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:6 by , 8 years ago
Easy pickings: | set |
---|---|
Summary: | Add precisions about setting the language for the test client → Document how to set the language for the test client |
Version: | 1.2 → master |
Looks like this could go in the test client documentation at docs/topics/testing/tools.txt
.
comment:7 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
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 by , 8 years ago
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 by , 8 years ago
Has patch: | set |
---|---|
Patch needs improvement: | set |
comment:10 by , 8 years ago
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.
BTW, the
activate/deactivate
functions fromdjango.utils.translation
aren't documented either.