File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8
1
2
from django .contrib import admin
2
3
from polls .models import Question , Choice
3
4
4
- admin .site .register (Question )
5
+
6
+ # class ChoiceInline(admin.StackedInline):
7
+ class ChoiceInline (admin .TabularInline ):
8
+ model = Choice
9
+ extra = 2
10
+
11
+
12
+ class QuestionAdmin (admin .ModelAdmin ):
13
+ # fields = ['pub_date', 'question_text'] # 필드 순서 변경
14
+ fieldsets = [
15
+ ('Question Statement' , {'fields' : ['question_text' ]}),
16
+ # ('Date Information', {'fields': ['pub_date']}),
17
+ ('Date Information' , {'fields' : ['pub_date' ],
18
+ 'classes' : ['collapse' ]}),
19
+ ] # 각 필드 분리하기
20
+
21
+ inlines = [ChoiceInline ] # Choice 모델 클래스 같이 보기
22
+ list_display = ('question_text' , 'pub_date' ) # 레코드 리스트 항목 지정
23
+ list_filter = ['pub_date' ] # 필터 사이드 바 추가
24
+ search_fields = ['question_text' ] # 검색 박스 추가
25
+
26
+
27
+
28
+
29
+ admin .site .register (Question , QuestionAdmin )
5
30
admin .site .register (Choice )
You can’t perform that action at this time.
0 commit comments