diff --git a/comments/admin.py b/comments/admin.py index f6ebfa8..c466a29 100644 --- a/comments/admin.py +++ b/comments/admin.py @@ -3,4 +3,12 @@ from django.contrib import admin # 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 106e5cf..6877eef 100644 --- a/comments/models.py +++ b/comments/models.py @@ -30,6 +30,9 @@ class Comment(models.Model): except: pass + def __str__(self): + return self.body + def save(self, *args, **kwargs): super().save(*args, **kwargs) subject = '感谢您发表的评论'