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.
Note:
See TracTickets
for help on using tickets.
It looks that you missed the distinct argument.
Please don't use Trac as a support channel. Closing per TicketClosingReasons/UseSupportChannels.