From a403aa73751f4be85c41ff1b5981d9c61bbe5b6f Mon Sep 17 00:00:00 2001 From: Zergling_man Date: Fri, 29 Oct 2021 05:05:42 +1100 Subject: [PATCH] Ah, right, a book with no chapters... --- books/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/books/models.py b/books/models.py index f9391ce..5b81ebc 100644 --- a/books/models.py +++ b/books/models.py @@ -9,7 +9,8 @@ class Book(models.Model): @property def last_updated(self): - return Chapter.objects.filter(book=self).order_by('added')[0].added + chaps=Chapter.objects.filter(book=self).order_by('added') + return chaps[0].added if chaps else None def __str__(self): return self.title