-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.py
33 lines (23 loc) · 1006 Bytes
/
admin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from django.contrib import admin
from poll_app.models import Question, Choice, Vote, Comment, IpModel
class ChoiceInline(admin.TabularInline):
model = Choice
extra = 3
@admin.register(Question)
class QuestionAdmin(admin.ModelAdmin):
fieldsets = [(None, {'fields': ['question_text', 'slug']}),
('Date information', {'fields': ['created_at']}),
('Active', {'fields': ['is_active']})]
inlines = [ChoiceInline]
readonly_fields = ['created_at']
list_display = ['id', 'question_text', 'slug', 'created_at', 'is_active']
prepopulated_fields = {'slug': ('question_text',)}
@admin.register(Vote)
class VoteAdmin(admin.ModelAdmin):
list_display = ['question', 'choice', 'voter', 'created_at']
@admin.register(Comment)
class CommentAdmin(admin.ModelAdmin):
list_display = ['author', 'question_relation', 'comment_text', 'created_at', 'is_active']
@admin.register(IpModel)
class IpAdmin(admin.ModelAdmin):
list_display = ['id', 'ip']