{{{
Entry.objects.annotate(num_authors=Count('authors')).aggregate(Avg('num_authors'))
}}}
but if we try the one below, it does not find the column ''authors__count'
to the aggregation
{{{
Entry.objects.annotate(Count('authors')).aggregate(Avg('authors__count'))
}}}
I believe it is a problem because the exception tells us we could use the
column ''''authors__count''''
This is what the exception says:
'''FieldError: Cannot resolve keyword 'count' into field. Choices are:
email, entry, id, name, authors__count''' <- see the field here.
Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/24065>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Old description:
> If we try this query, everything works normally
>
> {{{
> Entry.objects.annotate(num_authors=Count('authors')).aggregate(Avg('num_authors'))
> }}}
>
> but if we try the one below, it does not find the column
> ''authors__count' to the aggregation
>
> {{{
> Entry.objects.annotate(Count('authors')).aggregate(Avg('authors__count'))
> }}}
>
> I believe it is a problem because the exception tells us we could use the
> column ''''authors__count''''
>
> This is what the exception says:
>
> '''FieldError: Cannot resolve keyword 'count' into field. Choices are:
> email, entry, id, name, authors__count''' <- see the field here.
>
> Thanks.
New description:
If we try this query, everything works normally
{{{
Entry.objects.annotate(num_authors=Count('authors')).aggregate(Avg('num_authors'))
}}}
but if we try the one below, it does not find the column
{{{authors__count}}} to the aggregation
{{{
Entry.objects.annotate(Count('authors')).aggregate(Avg('authors__count'))
}}}
I believe it is a problem because the exception tells us we could use the
column {{{authors__count}}}
This is what the exception says:
{{{FieldError: Cannot resolve keyword 'count' into field. Choices are:
email, entry, id, name, authors__count}}} <- see the field here.
Thanks.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/24065#comment:1>
* status: new => closed
* resolution: => worksforme
Comment:
This works for me on current master. I haven't checked to see if it works
in 1.7 because I assume it doesn't from your bug report. I think #14030
would have fixed this bug.
--
Ticket URL: <https://code.djangoproject.com/ticket/24065#comment:2>