From e5fa609ba71583efeb25b7167c7e55708e3d8189 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Mon, 12 Mar 2007 09:21:22 +0000 Subject: [PATCH] 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 --- AUTHORS | 1 + django/views/i18n.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index 4a027fdd6e..760ffdd21e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -85,6 +85,7 @@ answer newbie questions, and generally made Django that much better: Marc Fargas favo@exoweb.net Eric Floehr + Jorge Gajon 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: