From da7baed79c6c6862e25a0a24a955af8659d7fe08 Mon Sep 17 00:00:00 2001 From: Midgard Date: Wed, 22 Jul 2020 17:28:39 +0200 Subject: [PATCH] Don't crash when not logged in --- events/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/events/models.py b/events/models.py index 4f4fcf4..1196c99 100644 --- a/events/models.py +++ b/events/models.py @@ -36,6 +36,9 @@ class Event(models.Model): def registration_of(self, user): + if not user.is_authenticated: + return None + registrations = self.eventregistration_set.filter(user=user).all() if not registrations: return None