django自定義管理表單

admin.pypython

from django.contrib import admin

# Register your models here.
from .models import Question,Choice
class ChoiceInline(admin.TabularInline):
    model = Choice
    extra = 3

class QuestionAdmin(admin.ModelAdmin):
    list_display = ('question_text', 'pub_date','tags')
    list_filter = ['pub_date','tags']
    search_fields = ['question_text','tags']
    fieldsets = [
        (None,               {'fields': ['question_text']}),
        ("TAGS",               {'fields': ['tags']}),
        ('Date information', {'fields': ['pub_date'], 'classes': ['collapse']}),
    ]
    inlines = [ChoiceInline]

admin.site.register(Question,QuestionAdmin)
相關文章
相關標籤/搜索