I want to write a query like SELECT * FROM users GROUP BY some_attribute
. How can I do that using Django ORM?
User.objects.all().values('some_attribute').annotate(count=Count('*'))
doesn't work, because it just selects some_attribute
, instead of *
- all.
I need it using the ORM, I don't want to write raw
statement.