Opened 4 years ago
Last modified 4 years ago
#32117 closed Uncategorized
Aggregation doesnt work with Models, ordered by Meta subclass — at Initial Version
Reported by: | eloktev | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 3.1 |
Severity: | Normal | Keywords: | aggregation, database, psycopg2 |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hello,
Using aggregation methods with models, that have set 'ordering' in Meta subclass fails:
class M1 (models.Model) date = models.DateField() smth = models.IntegerField() class Meta: ordeing = 'smth'
{{{{
count_by_day_qs = M1.objects.values('date').annotate(c=models.Count('id')).values('date', 'c')
}}}}
Returns executes following query:
{{{{
SELECT "m1"."date", COUNT("m1"."id") AS "c" FROM "m1" GROUP BY "m1"."date", "m1"."smth"
}}}}
Note:
See TracTickets
for help on using tickets.