From 5370d3feda5a0e3fad80ff51c7c2d887974a208c Mon Sep 17 00:00:00 2001 From: Ernesto Rico Schmidt <ernesto@helsinki.at> Date: Wed, 20 Nov 2024 15:16:48 -0400 Subject: [PATCH] fix: handle serializer context without request --- program/serializers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/serializers.py b/program/serializers.py index e9481b5..24d20e6 100644 --- a/program/serializers.py +++ b/program/serializers.py @@ -1038,7 +1038,7 @@ class TimeSlotSerializer(serializers.ModelSerializer): def to_representation(self, instance): representation = super().to_representation(instance) - if not self.context.get("request").user.is_authenticated: + if not (self.context.get("request") and self.context.get("request").user.is_authenticated): del representation["memo"] return representation -- GitLab