#36197: Model.relatedmanager.count() always 0 for custom ManyToMany
relationships
with through model with to_fields
-------------------------------------+-------------------------------------
Reporter: mfontana-elem | Owner: (none)
Type: Bug | Status: new
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 Sarah Boyce):
* cc: ontowhee, Simon Charette, Mariusz Felisiak (added)
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
* summary:
`Model.relatedmanager.count()` fails for custom ManyToMany
relationships with `through` definition
=>
Model.relatedmanager.count() always 0 for custom ManyToMany
relationships with through model with to_fields
Comment:
Thank you! Replicated and bisected to
66e47ac69a7e71cf32eee312d05668d8f1ba24bb (#29725)
Possible regression test/asserts
{{{#!diff
--- a/tests/m2m_through/tests.py
+++ b/tests/m2m_through/tests.py
@@ -521,6 +521,8 @@ class M2mThroughToFieldsTests(TestCase):
def test_retrieval(self):
# Forward retrieval
+ self.assertEqual(self.curry.ingredients.exists(), True)
+ self.assertEqual(self.curry.ingredients.count(), 3)
self.assertSequenceEqual(
self.curry.ingredients.all(), [self.pea, self.potato,
self.tomato]
)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36197#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/0107019513fd7232-7b306e1f-e9ef-4c36-a3c7-47a9cf0966e4-000000%40eu-central-1.amazonses.com.