From b6c9ce4763b9455c7add2a534f8a527c4767fd72 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Wed, 1 Nov 2023 21:50:36 -0500 Subject: [PATCH] Fix bug --- chat_box/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chat_box/models.py b/chat_box/models.py index d9837e7..fd35430 100644 --- a/chat_box/models.py +++ b/chat_box/models.py @@ -27,9 +27,10 @@ class Room(models.Model): @cache_wrapper(prefix="Rinfo") def _info(self): + last_msg = self.message_set.first() return { "user_ids": [self.user_one.id, self.user_two.id], - "last_message": self.message_set.first().body, + "last_message": last_msg.body if last_msg else None, } @cached_property