diff --git a/comments/admin.py b/comments/admin.py index f6ebfa8d..c466a290 100644 --- a/comments/admin.py +++ b/comments/admin.py @@ -3,4 +3,12 @@ # Register your models here. from .models import Comment -admin.site.register(Comment) + +class CommentAdmin(admin.ModelAdmin): + list_display = ('id', 'body', 'author', 'article', 'last_mod_time') + list_display_links = ('id', 'body') + list_filter = ('author', 'article',) + exclude = ('created_time', 'last_mod_time') + + +admin.site.register(Comment, CommentAdmin) diff --git a/comments/models.py b/comments/models.py index 106e5cf6..6877eef4 100644 --- a/comments/models.py +++ b/comments/models.py @@ -30,6 +30,9 @@ def send_comment_email(self, msg): except: pass + def __str__(self): + return self.body + def save(self, *args, **kwargs): super().save(*args, **kwargs) subject = '感谢您发表的评论'