[Django] #24065: aggregate dont find column of annotate

6 views
Skip to first unread message

Django

unread,
Dec 31, 2014, 9:02:00 AM12/31/14
to django-...@googlegroups.com
#24065: aggregate dont find column of annotate
-------------------------------------+-------------------------------------
Reporter: mateuspadua | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) | Keywords: aggregate annotate
Severity: Normal | fielderror
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
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>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 31, 2014, 9:05:04 AM12/31/14
to django-...@googlegroups.com
#24065: aggregate dont find column of annotate
-------------------------------------+-------------------------------------
Reporter: mateuspadua | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution:
Keywords: aggregate annotate | Triage Stage:
fielderror | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by mateuspadua):

* 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>

Django

unread,
Jan 1, 2015, 8:39:28 PM1/1/15
to django-...@googlegroups.com
#24065: aggregate dont find column of annotate
-------------------------------------+-------------------------------------
Reporter: mateuspadua | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 1.7
(models, ORM) | Resolution:
Severity: Normal | worksforme

Keywords: aggregate annotate | Triage Stage:
fielderror | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jarshwah):

* 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>

Reply all
Reply to author
Forward
0 new messages