Ticket #3640: i18n_set_language.diff

File i18n_set_language.diff, 924 bytes (added by Jorge Gajon <gajon@…>, 18 years ago)

Avoid MultiValueDictKeyError in set_language() view

  • django/views/i18n.py

     
    99    """
    1010    Redirect to a given url while setting the chosen language in the
    1111    session or cookie. The url and the language code need to be
    12     specified in the GET paramters.
     12    specified in the GET parameters.
    1313    """
    14     lang_code = request.GET['language']
     14    lang_code = request.GET.get('language', None)
    1515    next = request.GET.get('next', None)
    1616    if not next:
    1717        next = request.META.get('HTTP_REFERER', None)
    1818    if not next:
    1919        next = '/'
    2020    response = http.HttpResponseRedirect(next)
    21     if check_for_language(lang_code):
     21    if lang_code and check_for_language(lang_code):
    2222        if hasattr(request, 'session'):
    2323            request.session['django_language'] = lang_code
    2424        else:
Back to Top