Opened 2 hours ago

Last modified 2 hours ago

#36773 new Bug

ManyToMany related manager .count() returns 0 while .all().count() returns correct value (Django 5.2.9 and 6.0.0)

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 Daniel Davtyan)

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.

Change History (1)

comment:1 by Daniel Davtyan, 2 hours ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top