From ccc7a595bafbaea537c9ffaa5bf6cfcd6c090099 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Mon, 9 Sep 2024 20:25:46 -0400 Subject: [PATCH] reservations: Fix Reservation.__repr__ being sometimes recursively defined --- reservations/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/reservations/models.py b/reservations/models.py index e3ffc95..1c25ad6 100644 --- a/reservations/models.py +++ b/reservations/models.py @@ -104,6 +104,10 @@ class Reservation(models.Model): resources = ", ".join(str(resource) for resource in self.resources.all()) return f"{resources}: {self.start} - {self.end}" + def __repr__(self) -> str: + """Redefined to avoid __str__ and therefore .resources, which was causing recursion issues""" + return f"<{self.__class__.__name__}: {self.start} - {self.end}>" + def get_title(self) -> str: return "Unknown Reservation"