From cb387658ff15265cb6481f7528ff70270d901a9e Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 20 Nov 2024 08:46:28 +0700 Subject: [PATCH] fix: error in rare cases where cookies are not populated yet --- basxbread/middleware.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/basxbread/middleware.py b/basxbread/middleware.py index 2df3afbf..6068da71 100644 --- a/basxbread/middleware.py +++ b/basxbread/middleware.py @@ -46,7 +46,9 @@ def __call__(self, request): timezone.activate(zoneinfo.ZoneInfo(tz)) else: timezone.deactivate() - if not tz and "basxbread-timezone" in request.session["basxbread-cookies"]: + if not tz and "basxbread-timezone" in request.session.get( + "basxbread-cookies", {} + ): timezone.activate( zoneinfo.ZoneInfo( request.session["basxbread-cookies"]["basxbread-timezone"]