Spruce up news admin view
Add last modified date as a column, and fix up some other small display, sorting, and ordering issues. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
b084936ad9
commit
8a3bd1ad8a
@ -3,8 +3,8 @@
|
||||
from .models import News
|
||||
|
||||
class NewsAdmin(admin.ModelAdmin):
|
||||
list_display = ('title', 'author', 'postdate')
|
||||
list_filter = ('author', 'postdate')
|
||||
list_display = ('title', 'author', 'postdate', 'last_modified')
|
||||
list_filter = ('postdate', 'author')
|
||||
search_fields = ('title', 'content')
|
||||
|
||||
admin.site.register(News, NewsAdmin)
|
||||
|
@ -4,7 +4,7 @@
|
||||
class News(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
author = models.ForeignKey(User, related_name='news_author')
|
||||
postdate = models.DateTimeField(auto_now_add=True, db_index=True)
|
||||
postdate = models.DateTimeField("post date", auto_now_add=True, db_index=True)
|
||||
last_modified = models.DateTimeField(editable=False,
|
||||
auto_now=True, db_index=True)
|
||||
title = models.CharField(max_length=255)
|
||||
@ -20,6 +20,6 @@ class Meta:
|
||||
db_table = 'news'
|
||||
verbose_name_plural = 'news'
|
||||
get_latest_by = 'postdate'
|
||||
ordering = ['-postdate', '-id']
|
||||
ordering = ['-postdate']
|
||||
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
Loading…
Reference in New Issue
Block a user