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
This commit is contained in:
Malcolm Tredinnick 2007-03-12 09:21:22 +00:00
parent 2a488f3cd4
commit e5fa609ba7
2 changed files with 4 additions and 3 deletions

View File

@ -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

View File

@ -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: