on
[Django] admin.ModelAdmin objects 정리
[Django] admin.ModelAdmin objects 정리
# admin.py # ModelAdmin의 options을 설정해 주어 admin page에서 원하는 정보를 customize한다. # 기본적으로 tuple 혹은 list로 감싸준다. """fieldsets""" #detail페이지 에서 볼 내용들 #1. 튜플(혹은 리스트 이하 동일)로 감싼다 (최상) #2. 튜플(혹은 리스트)은 각각의 객체이다. 1번째는 fields 묶음의 이름, 이하는 포함된 fields #3. 1번째 인자인 이름은 str #4. 2번째 인자인 fields는 dict #5. dict안에 key는 "fields, value는 튜플안에 str fieldsets = ( ( "Basic Info", {"fields": ("name", "description", "country", "address", "price")}, ), ) """list_display""" # column에서 preview할 fields 설정 list_display = ( "name", "country", "city", ) """list_filter""" # 화면에 보여줄 데이터를 필터링할 항목들을 추가한다. list_filter = ( "instant_book", "host__superhost", "room_type", "amenities", "facilities", "house_rules", "city", "country", ) """search_fields""" # 화면에 보여줄 데이터를 검색하는 내용에 대한 설정 # 아래와 같이 fields = city로 하면 city에 대한 value들에 대해서 indexing한다 search_fields = ("city",) """filter_horizontal""" # ManytoMany 속성을 가진 값들에 대한 설정 filter_horizontal = ( "amenities", "facilities", "house_rules", )
fieldsets
list_display list_filter search_fields filter_horizontal
from http://insubkim.tistory.com/134 by ccl(A) rewrite - 2021-12-03 23:27:16