Old 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"
> }}}}
New 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"
}}}}
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32117#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
New description:
#Executes following query:
SELECT "m1"."date", COUNT("m1"."id") AS "c" FROM "m1" GROUP BY
"m1"."date", "m1"."smth"
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32117#comment:2>
* owner: nobody => Dede Dian
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/32117#comment:3>
* status: assigned => closed
* resolution: => invalid
Comment:
This is documented as a caveat of performing aggregation against a model
with a defined `Meta.ordering`
https://docs.djangoproject.com/en/3.1/topics/db/aggregation/#interaction-
with-default-ordering-or-order-by
Please TicketClosingReasons/UseSupportChannels before filling a ticket in
the future.
--
Ticket URL: <https://code.djangoproject.com/ticket/32117#comment:4>