diff --git a/scipost_django/comments/models.py b/scipost_django/comments/models.py index a3c0367d53a8fb28961c29bc4e035b60f2b870a3..b5b3a8d30b8407fe6e947b461f165a74b676b0e1 100644 --- a/scipost_django/comments/models.py +++ b/scipost_django/comments/models.py @@ -84,8 +84,11 @@ class Comment(TimeStampedModel): ) def __str__(self): - return ('by ' + self.author.user.first_name + ' ' + self.author.user.last_name + - ' on ' + self.date_submitted.strftime('%Y-%m-%d') + ', ' + self.comment_text[:30]) + text = "Anonymous" + if not self.anonymous: + text = self.author.user.first_name + ' ' + self.author.user.last_name + return (text + ' on ' + + self.date_submitted.strftime('%Y-%m-%d') + ', ' + self.comment_text[:30]) @property def title(self):