2013. 4. 1. 17:08
프로그래밍/장고
장고에서 단순히 Object의 갯수만을 세고 싶을때는 .count()를 사용하면 된다.
count
- count()
Returns an integer representing the number of objects in the database matching the QuerySet. The count() method never raises exceptions.
Example:
# Returns the total number of entries in the database.
Entry.objects.count()
# Returns the number of entries whose headline contains 'Lennon'
Entry.objects.filter(headline__contains='Lennon').count()