Django 튜토리얼

장고 튜토리얼 개발 정리

Django 튜토리얼 장고 튜토리얼 개발 정리

Part 7

Writing your first Django app, part 7

https://docs.djangoproject.com/en/3.0/intro/tutorial07/

Github Tag: https://github.com/studroid/writing-your-fisrt-django-app/commits/Part-7-Finished 

참고 자료

admin.py에서 register(model, optionClass) 사용 시 optionClass의 속성으로 사용할 수 있는 요소들
field: 데이터 추가/수정 시 보여줄 필드 순서 정의
fieldsets: 데이터 추가/수정 시 여러 필드를 하나의 이름으로 묶어 해당 이름 하위에 순서대로 정의
inlines: A 모델에 B 모델이 참조 관계(외래 키)로 엮여있는 경우, A 모델에 데이터를 등록할 때 B 모델 데이터를                 한 페이지에서 동시에 등록할 수 있게 함.
list_display: 한 모델에 이미 등록된 데이터 리스트 페이지에 보여줄 미리보기 항목들을 지정할 수 있음.
                    모델에 등록된 메소드도 등록 가능.
list_filter: 어드민 사이트 우측에 필드 타입에 따라 표시할 데이터 필터링 기준을 만들어 제공
search_fields: 필드 데이터 검색용 Search Box를 만들어 제공 (원본 데이터 대상으로, 문자열로만 가능)
date_hierarchy: DateField 또는 DateTimeField 형식의 필드를 지정하면, 전체 데이터의 날짜 범위에 따라 자동
                           으로 범주를 만들어, 리스트에 표시할 데이터의 날짜 범위를 선택하여 필터링할 수 있게 함
list_display에 등록하는 메소드에 표시 이름 변경, 정렬 기준 설정, 표시 형식 변경 등 설정할 수 있는 항목에 대한 더 자세한 설명
For more information on these method properties, see list_display.
Django admin site에 대한 더 자세한 설명(Template Override 등 포함)
https://docs.djangoproject.com/en/3.0/ref/contrib/admin/

Organizing templates

Just like the static files, we could have all our templates together, in one big templates directory, and it would work perfectly well. However, templates that belong to a particular application should be placed in that application’s template directory (e.g. polls/templates) rather than the project’s (templates). We’ll discuss in more detail in the reusable apps tutorial why we do this.

 터미널에서 Django 설치 경로 찾기 명령어
python -c "import django; print(django.__path__)"
We use this approach to teach you how to override templates. In an actual project, you would probably use the django.contrib.admin.AdminSite.site_header attribute to more easily make this particular customization. 
AdminSite의 속성 Override, 앱별 Admin 만들기 등에 대한 추가 정보
https://docs.djangoproject.com/en/3.0/ref/contrib/admin/#customizing-the-adminsite-class 

댓글

댓글 본문
버전 관리
김시준
현재 버전
선택 버전
graphittie 자세히 보기