I'm working with Django and I need to group a model by multiple fields.
The query I want is:
select field1, field2 from tbl group by field1, field2 having count(*) > 1
Then what I've tried is the following:
Tbl.objects.annotate(cnt=Count('field1','field2')).filter(cnt__gt=1)
But, it didn't work.
Can't group by multiple fields on ORM?
Do I need to write RawQuery?