|
2 | 2 | from .models import Poll, Choice, Vote |
3 | 3 |
|
4 | 4 |
|
5 | | -class ChoiceInline(admin.TabularInline): # or admin.StackedInline for a different layout |
6 | | - model = Choice |
7 | | - extra = 1 |
8 | | - |
9 | 5 | @admin.register(Poll) |
10 | 6 | class PollAdmin(admin.ModelAdmin): |
11 | | - list_display = ["text", "owner", "pub_date", "active", "created_at"] |
| 7 | + list_display = ["text", "owner", "pub_date", "active"] |
12 | 8 | search_fields = ["text", "owner__username"] |
13 | | - list_filter = ["active", 'created_at', 'pub_date'] |
| 9 | + list_filter = ["active"] |
14 | 10 | date_hierarchy = "pub_date" |
15 | | - inlines = [ChoiceInline] |
16 | 11 |
|
17 | 12 |
|
18 | 13 | @admin.register(Choice) |
19 | 14 | class ChoiceAdmin(admin.ModelAdmin): |
20 | | - list_display = ["choice_text", "poll", 'created_at', 'updated_at'] |
| 15 | + list_display = ["choice_text", "poll"] |
21 | 16 | search_fields = ["choice_text", "poll__text"] |
22 | 17 | autocomplete_fields = ["poll"] |
23 | 18 |
|
24 | 19 |
|
25 | 20 | @admin.register(Vote) |
26 | 21 | class VoteAdmin(admin.ModelAdmin): |
27 | | - list_display = ["choice", "poll", "user", 'created_at'] |
| 22 | + list_display = ["choice", "poll", "user"] |
28 | 23 | search_fields = ["choice__choice_text", "poll__text", "user__username"] |
29 | 24 | autocomplete_fields = ["choice", "poll", "user"] |
0 commit comments