mirror of
https://github.com/jazzband/django-admin2.git
synced 2026-04-28 10:34:46 +00:00
Improved PollAdmin.
This commit is contained in:
parent
0fe407565d
commit
320c6b6d4b
2 changed files with 6 additions and 2 deletions
|
|
@ -3,7 +3,6 @@ import djadmin2
|
|||
from .models import Poll, Choice
|
||||
|
||||
|
||||
# class ChoiceInline(admin.StackedInline):
|
||||
class ChoiceInline(djadmin2.Admin2Inline):
|
||||
model = Choice
|
||||
extra = 3
|
||||
|
|
@ -16,7 +15,9 @@ class PollAdmin(djadmin2.ModelAdmin2):
|
|||
]
|
||||
inlines = [ChoiceInline]
|
||||
list_display = ('question', 'pub_date', 'was_published_recently')
|
||||
list_filter = ['pub_date']
|
||||
search_fields = ['question']
|
||||
date_hierarchy = 'pub_date'
|
||||
|
||||
|
||||
djadmin2.default.register(Poll, PollAdmin)
|
||||
djadmin2.default.register(Choice)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ class Poll(models.Model):
|
|||
|
||||
def was_published_recently(self):
|
||||
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
|
||||
was_published_recently.admin_order_field = 'pub_date'
|
||||
was_published_recently.boolean = True
|
||||
was_published_recently.short_description = 'Published recently?'
|
||||
|
||||
|
||||
class Choice(models.Model):
|
||||
|
|
|
|||
Loading…
Reference in a new issue