like:
Number of authors by category:
{{{
#!python
Author.objects.values('post__category__name').aggregate(qtd=Count('id',
distinct=True))
}}}
There is nothing on the internet or in the documentation and talking
something about it. I find that looking at the code.
--
Ticket URL: <https://code.djangoproject.com/ticket/19313>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Internal APIs aren't documented because they're subject to change without
warning.
Could you check if the following query — which only uses documented APIs —
achieves the same result?
{{{
Author.objects.values('post__category__name').distinct('id').aggregate(qtd=Count('id'))
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/19313#comment:1>
Comment (by anonymous):
Hi!
distinct by column name isn't suported by mysql backend.
--
Ticket URL: <https://code.djangoproject.com/ticket/19313#comment:2>
* stage: Unreviewed => Accepted
Comment:
I'm comfortable calling this an oversight on my part. SELECT
COUNT(DISTINCT foo) FROM table is different to SELECT DISTINCT COUNT(foo)
FROM table, and support for distinct counts was a deliberate decision.
Although it's a feature that may not be universally available on all
databases, it is useful on those databases that support it.
--
Ticket URL: <https://code.djangoproject.com/ticket/19313#comment:3>
Comment (by jorgecarleitao):
This can be documented when ticket #14030 is addressed.
--
Ticket URL: <https://code.djangoproject.com/ticket/19313#comment:4>
Comment (by jorgecarleitao):
Forget previous comment.
Isn't this documented in Count,
https://docs.djangoproject.com/en/1.6/ref/models/querysets/#django.db.models.Count.distinct,
which is different from distinct,
https://docs.djangoproject.com/en/1.6/ref/models/querysets/#distinct ?
--
Ticket URL: <https://code.djangoproject.com/ticket/19313#comment:5>
* status: new => closed
* resolution: => worksforme
Comment:
Yep, that looks like it.
--
Ticket URL: <https://code.djangoproject.com/ticket/19313#comment:6>