diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-03-12 09:21:22 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-03-12 09:21:22 +0000 |
| commit | e5fa609ba71583efeb25b7167c7e55708e3d8189 (patch) | |
| tree | 41912a8282ff5f66fe9283528a049a420b4f6369 | |
| parent | 2a488f3cd412ad899ce32f3603cbc02db8f6c187 (diff) | |
Fixed #3640 -- Improved error handling in views.i18n.set_language(). Thanks
Jorge Gajon.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4708 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | AUTHORS | 1 | ||||
| -rw-r--r-- | django/views/i18n.py | 6 |
2 files changed, 4 insertions, 3 deletions
@@ -85,6 +85,7 @@ answer newbie questions, and generally made Django that much better: Marc Fargas <telenieko@telenieko.com> favo@exoweb.net Eric Floehr <eric@intellovations.com> + Jorge Gajon <gajon@gajon.org> gandalf@owca.info Baishampayan Ghose martin.glueck@gmail.com diff --git a/django/views/i18n.py b/django/views/i18n.py index b5eb32bda3..0a19cfe986 100644 --- a/django/views/i18n.py +++ b/django/views/i18n.py @@ -9,16 +9,16 @@ def set_language(request): """ Redirect to a given url while setting the chosen language in the session or cookie. The url and the language code need to be - specified in the GET paramters. + specified in the GET parameters. """ - lang_code = request.GET['language'] + lang_code = request.GET.get('language', None) next = request.GET.get('next', None) if not next: next = request.META.get('HTTP_REFERER', None) if not next: next = '/' response = http.HttpResponseRedirect(next) - if check_for_language(lang_code): + if lang_code and check_for_language(lang_code): if hasattr(request, 'session'): request.session['django_language'] = lang_code else: |
