However I am not able to get the desired query. It keeps on adding group
by id which is not what I want.
Django query:
result = query.annotate(person=Concat(F('field1'),
F('field2'))).annotate(Count('person', distinct=True))
Outputs:
SELECT id FROM table WHERE my condition GROUP BY id ORDER BY field
Please let me know if you have any questions.
--
Ticket URL: <https://code.djangoproject.com/ticket/30633>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* component: Uncategorized => Database layer (models, ORM)
* version: 2.2 => master
* resolution: => invalid
Comment:
I'm not sure what exactly you want to achieve because your expected query
and Django queryset are slightly different, but my understanding is that
`values()` is missing:
{{{
query.annotate(person=Concat('field1',
'field2')).values('person').annotate(Count('person', distinct=True))
}}}
Moreover this is a support question not a bug in Django, please use one of
[https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels
support channels].
--
Ticket URL: <https://code.djangoproject.com/ticket/30633#comment:1>