Re: [Django] #36197: Model.relatedmanager.count() always 0 for custom ManyToMany relationships with through model with to_fields

11 views
Skip to first unread message

Django

unread,
Feb 17, 2025, 9:14:50 AM2/17/25
to django-...@googlegroups.com
#36197: Model.relatedmanager.count() always 0 for custom ManyToMany relationships
with through model with to_fields
-------------------------------------+-------------------------------------
Reporter: mfontana-elem | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* owner: (none) => Simon Charette
* status: new => assigned

Comment:

I can work on that one.

We can't be systematically using `self.instance.pk`
[https://github.com/django/django/blob/0d1dd6bba0c18b7feb6caa5cbd8df80fbac54afd/django/db/models/fields/related_descriptors.py#L1175
here]
--
Ticket URL: <https://code.djangoproject.com/ticket/36197#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 17, 2025, 1:48:36 PM2/17/25
to django-...@googlegroups.com
#36197: Model.relatedmanager.count() always 0 for custom ManyToMany relationships
with through model with to_fields
-------------------------------------+-------------------------------------
Reporter: mfontana-elem | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36197#comment:4>

Django

unread,
Feb 18, 2025, 4:47:37 AM2/18/25
to django-...@googlegroups.com
#36197: Model.relatedmanager.count() always 0 for custom ManyToMany relationships
with through model with to_fields
-------------------------------------+-------------------------------------
Reporter: mfontana-elem | Owner: Simon
| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36197#comment:5>

Django

unread,
Feb 18, 2025, 5:43:36 AM2/18/25
to django-...@googlegroups.com
#36197: Model.relatedmanager.count() always 0 for custom ManyToMany relationships
with through model with to_fields
-------------------------------------+-------------------------------------
Reporter: mfontana-elem | Owner: Simon
| Charette
Type: Bug | Status: closed
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"c3a23aa02faa1cf1d32e43d66858e793cd9ecac4" c3a23aa]:
{{{#!CommitTicketReference repository=""
revision="c3a23aa02faa1cf1d32e43d66858e793cd9ecac4"
Fixed #36197 -- Fixed improper many-to-many count() and exists() for non-
pk to_field.

Regression in 66e47ac69a7e71cf32eee312d05668d8f1ba24bb.

Thanks mfontana-elem for the report and Sarah for the tests.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36197#comment:6>

Django

unread,
Feb 18, 2025, 5:45:18 AM2/18/25
to django-...@googlegroups.com
#36197: Model.relatedmanager.count() always 0 for custom ManyToMany relationships
with through model with to_fields
-------------------------------------+-------------------------------------
Reporter: mfontana-elem | Owner: Simon
| Charette
Type: Bug | Status: closed
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"6b8a6e1251e57b7bfee1ab6880171376a3a1a394" 6b8a6e1]:
{{{#!CommitTicketReference repository=""
revision="6b8a6e1251e57b7bfee1ab6880171376a3a1a394"
[5.2.x] Fixed #36197 -- Fixed improper many-to-many count() and exists()
for non-pk to_field.

Regression in 66e47ac69a7e71cf32eee312d05668d8f1ba24bb.

Thanks mfontana-elem for the report and Sarah for the tests.

Backport of c3a23aa02faa1cf1d32e43d66858e793cd9ecac4 from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36197#comment:7>

Django

unread,
Feb 18, 2025, 5:46:29 AM2/18/25
to django-...@googlegroups.com
#36197: Model.relatedmanager.count() always 0 for custom ManyToMany relationships
with through model with to_fields
-------------------------------------+-------------------------------------
Reporter: mfontana-elem | Owner: Simon
| Charette
Type: Bug | Status: closed
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"8488074fe38edbea6c4ec822c59c7c45d0669a91" 8488074f]:
{{{#!CommitTicketReference repository=""
revision="8488074fe38edbea6c4ec822c59c7c45d0669a91"
[5.1.x] Fixed #36197 -- Fixed improper many-to-many count() and exists()
for non-pk to_field.

Regression in 66e47ac69a7e71cf32eee312d05668d8f1ba24bb.

Thanks mfontana-elem for the report and Sarah for the tests.

Backport of c3a23aa02faa1cf1d32e43d66858e793cd9ecac4 from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36197#comment:8>
Reply all
Reply to author
Forward
0 new messages