Model.objects.all()
Model.objects.exist()
count1 = len(list(Model.objects.all()))
count2 = Model.objects.all().count() (DB단 처리)
User.objects.annotate(컬럼명=표현식)
# 컬럼명 표시 안했을때
User.objects.annotate(Count('is_active'))
id | username | password | is_active | is_active__count | |
---|---|---|---|---|---|
1 | gildong Hong | test@naver.com | qwer1234! | True | 1 |
2 | minsu Kim | test2@gmail.com | q1w2e3r4! | True | 1 |
3 | mansu Park | test3@yahoo.co.kr | 123qwer4! | False | 1 |