Opened 4 hours ago
Last modified 33 minutes ago
#36773 closed Bug
ManyToMany related manager .count() returns 0 while .all().count() returns correct value (Django 5.2.9 and 6.0.0) — at Version 1
| Reported by: | Daniel Davtyan | Owned by: | |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 6.0 |
| Severity: | Release blocker | Keywords: | count, django, orm |
| Cc: | Daniel Davtyan | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Environment
Django: 5.2.9
Python: 3.12.x
Database: PostgreSQL
OS: Ubuntu 22.04
The same code previously worked correctly on Django 4.x. After upgrading to Django 5.x (now 6.0), I see a discrepancy between ManyToMany related manager .count() and .all().count() in tests.
This looks similar to the regression tracked as #36197, which was fixed for ManyToManyField related managers using a through model with to_field, but I am still seeing the same symptom on Django 5.2.9.
Note:
See TracTickets
for help on using tickets.