오픈소스/Django

django opensource study - CryceTruly/django-tutorial-youtube

bluebamus 2022. 11. 16.

youtube channel : https://www.youtube.com/c/CryceTruly/playlists

 

Cryce Truly

Learn all about the cutting edge technology in software development and create great applications.

www.youtube.com

youtube admin class : https://www.youtube.com/watch?v=2Tw9eBpMel0&list=PLx-q4INfd95ESFMQ1Je3Z0gFdQLhrEuY7&index=36 

git page : https://github.com/CryceTruly/django-tutorial-youtube

 

GitHub - CryceTruly/django-tutorial-youtube

Contribute to CryceTruly/django-tutorial-youtube development by creating an account on GitHub.

github.com

 

- admin 설정과 관련하여 중요한 점은 admin의 base_site.html을 오버라이딩 했다는 부분이다.

프로젝트 설정 폴더인 todosite에 static 폴더가 있으며 해당 폴더 아래 css/admin/admin.css를 추가로 생성하여 참조했다.

 

해당 프로젝트를 굳이 정리하고자 하는 이유로는 몇가지 기록을 해둘 자료가 있기 때문이다.

 

1. urls.py에 handler404, handler500를 선언하였으며 각각의 에러 출력 함수는 helpers/views.py에 정의하였다.

 - 이렇게 정의해 관리하는 것이 깔끔해 보였음

 

2. 데코레이터 user_passes_test

- 원형 : user_passes_test(test_func, login_url=None, redirect_field_name='next')

- test_func이 false되면 redirect가 수행된다.

    - 유저가 프리미엄 유저인지, 포인트등의 조건에 따라 이동하게 만들수도 있음

-reference : 

https://docs.djangoproject.com/en/4.1/topics/auth/default/

 

Django

The web framework for perfectionists with deadlines.

docs.djangoproject.com

https://dbza.tistory.com/entry/5-%EC%9E%A5%EA%B3%A0-Views2

 

5. 장고 Views(2)

DRF-React Study Chapter 3. 장고 Views 장고 기본 CBV API (Base Views) Base Views django/views/generic/base.py View TemplateView TemplateResponseMixin ContextMixin RedirectView View 모든 CBV의 모체 http method별로 지정 이름의 멤버함수

dbza.tistory.com

https://devdongbaek.tistory.com/74

 

Django 뷰 장식자(Decorators)

출처 : https://www.inflearn.com/course/%ED%8C%8C%EC%9D%B4%EC%8D%AC-%EC%9E%A5%EA%B3%A0-%EC%9B%B9%EC%84%9C%EB%B9%84%EC%8A%A4/dashboard 장고(Django)를 배우기 시작한 입문자이시거나, 또는 배우고 싶은 생각이 있으신 분은 위 출

devdongbaek.tistory.com

https://micropyramid.medium.com/custom-decorators-to-check-user-roles-and-permissions-in-django-ece6b8a98d9d

 

Custom Decorators To Check User Roles And Permissions In Django

A decorator is a function that takes another function and returns a newer, prettier version of that function.

micropyramid.medium.com

3. Faker를 이용한 테스트 사용자 자동 추가

- test를 하기 위해서는 사전 데이터가 필요하다 

- Faker를 사용하면 이러한 데이터를 사전에 만들 수 있다. Factoryboy도 훌륭함

- 위치 : utils/setup_test.py

'오픈소스 > Django' 카테고리의 다른 글

Django의 classonlymethod 알아보기  (0) 2021.06.20
django blog와 관련한 github 오픈소스 모음  (0) 2021.06.13

댓글