Opened 10 years ago

Last modified 10 years ago

#24065 closed Bug

aggregate dont find column of annotate — at Initial Version

Reported by: mateuspadua Owned by: nobody
Component: Database layer (models, ORM) Version: 1.7
Severity: Normal Keywords: aggregate annotate fielderror
Cc: mateuspaduaweb@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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 authorscount' 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 'authorscount'

This is what the exception says:

FieldError: Cannot resolve keyword 'count' into field. Choices are: email, entry, id, name, authorscount <- see the field here.

Thanks.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top