Opened 4 years ago

Closed 4 years ago

#31873 closed Uncategorized (invalid)

Count in query giving undesired results across models

Reported by: nikijoe Owned by: nobody
Component: Database layer (models, ORM) Version: 3.1
Severity: Normal Keywords: model query
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have models Bill and BillProducts, having Foreignkey relation to Bill with fieldname bill. If i try count = BillProducts.objects.aggregate(billcount=Count('bill')) it is giving wrong results. But count = Bill.objects.aggregate(billcount=Count('id')) giving correct results.

Change History (1)

comment:1 by Mariusz Felisiak, 4 years ago

Resolution: invalid
Status: newclosed

It looks that you missed the distinct argument.

Please don't use Trac as a support channel. Closing per TicketClosingReasons/UseSupportChannels.

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