From 027dd528db06d5c4c7f9833cabfbef52a809b535 Mon Sep 17 00:00:00 2001 From: fonfon Date: Sun, 22 Nov 2015 10:34:58 +0100 Subject: [PATCH] Fix KeyError on first run when no language is set --- plinth/modules/config/config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plinth/modules/config/config.py b/plinth/modules/config/config.py index 6b7aaefcf..a39173323 100644 --- a/plinth/modules/config/config.py +++ b/plinth/modules/config/config.py @@ -59,8 +59,9 @@ def get_language(request): # taking care of setting language on login, and adapting kvstore when # renaming/deleting users - # The session contains more accurate information than request.LANGUAGE_CODE - return request.session[translation.LANGUAGE_SESSION_KEY] + # The information from the session is more accurate but not always present + return request.session.get(translation.LANGUAGE_SESSION_KEY, + request.LANGUAGE_CODE) class TrimmedCharField(forms.CharField):