diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-02-19 09:19:38 +0000 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-02-19 09:19:38 +0000 |
| commit | cfd0cb00647ac5ccf48c775605eafbade07217d7 (patch) | |
| tree | 8fe6aaa15afd62f7c94f31deb507cff2afb9e626 /docs/topics | |
| parent | 1d78897c5de5bc387dabd997ed8e64dd541708bb (diff) | |
Fixed #17319 -- Made the example for set_language less error-prone. Thanks Anna Dolma Alonso for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17560 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/topics')
| -rw-r--r-- | docs/topics/i18n/translation.txt | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt index ed4b2d4b89..6bb6a0c5e4 100644 --- a/docs/topics/i18n/translation.txt +++ b/docs/topics/i18n/translation.txt @@ -1240,7 +1240,8 @@ The ``set_language`` redirect view .. function:: set_language(request) As a convenience, Django comes with a view, :func:`django.views.i18n.set_language`, -that sets a user's language preference and redirects back to the previous page. +that sets a user's language preference and redirects to a given URL or, by default, +back to the previous page. Activate this view by adding the following line to your URLconf:: @@ -1269,7 +1270,7 @@ Here's example HTML template code: <form action="/i18n/setlang/" method="post"> {% csrf_token %} - <input name="next" type="hidden" value="/next/page/" /> + <input name="next" type="hidden" value="{{ redirect_to }}" /> <select name="language"> {% get_language_info_list for LANGUAGES as languages %} {% for language in languages %} @@ -1279,6 +1280,9 @@ Here's example HTML template code: <input type="submit" value="Go" /> </form> +In this example, Django looks up the URL of the page to which the user will be +redirected in the ``redirect_to`` context variable. + Using translations outside views and templates ---------------------------------------------- |
