'how Count field using django orm
Solution 1:[1]
Look at https://pythonguides.com/python-django-group-by/
Type.objects.values('status').annotate(
status_count=Count('id')
).values(
'status', 'status_count'
).order_by()
EDIT: count only in active status
Type.objects.filter(status='active').aggregate(
active_count=Count('status')
).values('active_count')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

