27 lines
745 B
Python
27 lines
745 B
Python
|
from django.contrib import admin
|
||
|
|
||
|
# Register your models here.
|
||
|
|
||
|
from .models import Choice, Question
|
||
|
|
||
|
|
||
|
class ChoiceInLine(admin.TabularInline):
|
||
|
model = Choice
|
||
|
extra = 3
|
||
|
|
||
|
|
||
|
class QuestionAdmin(admin.ModelAdmin):
|
||
|
# https://docs.djangoproject.com/en/1.11/intro/tutorial07/
|
||
|
search_fields = ['question_text'] # interesting, seems we can then search on this
|
||
|
list_filter = ['pub_date']
|
||
|
list_display = ('question_text', 'pub_date', 'was_published_recently')
|
||
|
fieldsets = [
|
||
|
(None, {'fields': ['question_text']}),
|
||
|
('Date information', {'fields': ['pub_date']}),
|
||
|
]
|
||
|
inlines = [ChoiceInLine]
|
||
|
|
||
|
|
||
|
admin.site.register(Question, QuestionAdmin)
|
||
|
admin.site.register(Choice)
|