My model:
class Device(models.Model):
build = models.CharField()
name = models.CharField()
How do I build my queryset so I can get the count of objects with different builds.
For example if there were two builds ‘build 1’ and ‘build 2’, I would want an output that would tell me
build 1 = 3
build 2 = 4
EDIT: Tried the following:
Device.objects.values('build').annotate(count=Count('pk'))
the output is:
[{'build': u'wed build'}, {'build': u'red build'}, ... ]
1 Answer