Last active
March 21, 2018 13:51
-
-
Save LowerDeez/3c87cd35b39ec39f3dfb2b0705c59032 to your computer and use it in GitHub Desktop.
Django. Get count of objects filtered by choices.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kwargs['count'] = { | |
v['status']: v['status__count'] | |
for v in | |
self.get_queryset().values('status').annotate(Count('status')).order_by('status') | |
} | |
# status = model choice field |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment