From fbfceecc93f6e78e662d717f2a80f5f6ba9cd6de Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Thu, 20 Aug 2020 10:22:18 +0200 Subject: [PATCH] Add str to comment --- articles/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/articles/models.py b/articles/models.py index bbe4454..2788d4a 100644 --- a/articles/models.py +++ b/articles/models.py @@ -134,5 +134,8 @@ class Comment(AdminUrlMixin, models.Model): class Meta: ordering = ["created_at"] + def __str__(self): + return f"{self.username} - {self.content[:50]}" + def get_absolute_url(self): return self.article.get_absolute_url() + "#" + str(self.id)