Changeset 6177
- Timestamp:
- 09/14/07 02:33:45 (8 months ago)
- Files:
-
- django/trunk/django/views/i18n.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/views/i18n.py
r5849 r6177 10 10 Redirect to a given url while setting the chosen language in the 11 11 session or cookie. The url and the language code need to be 12 specified in the GET parameters. 12 specified in the request parameters. 13 14 Since this view changes how the user will see the rest of the site, it must 15 only be accessed as a POST request. If called as a GET request, it will 16 redirect to the page in the request (the 'next' parameter) without changing 17 any state. 13 18 """ 14 lang_code = request.GET.get('language', None)15 19 next = request.GET.get('next', None) 16 20 if not next: … … 19 23 next = '/' 20 24 response = http.HttpResponseRedirect(next) 21 if lang_code and check_for_language(lang_code): 22 if hasattr(request, 'session'): 23 request.session['django_language'] = lang_code 24 else: 25 response.set_cookie('django_language', lang_code) 25 if request.method == 'POST': 26 lang_code = request.POST.get('language', None) 27 if lang_code and check_for_language(lang_code): 28 if hasattr(request, 'session'): 29 request.session['django_language'] = lang_code 30 else: 31 response.set_cookie('django_language', lang_code) 26 32 return response 27 33
