summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2025-02-17 13:45:31 -0500
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-02-18 11:44:46 +0100
commit6b8a6e1251e57b7bfee1ab6880171376a3a1a394 (patch)
tree0af31e19d5f6b28b5c41ba26d3582940a4a5b415 /tests
parentb0d497ada04bb6dccdfc2c4072744de391b7d3b7 (diff)
[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.
Diffstat (limited to 'tests')
-rw-r--r--tests/m2m_through/tests.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/m2m_through/tests.py b/tests/m2m_through/tests.py
index 83449a7c7b..81a47a2083 100644
--- a/tests/m2m_through/tests.py
+++ b/tests/m2m_through/tests.py
@@ -533,3 +533,11 @@ class M2mThroughToFieldsTests(TestCase):
[choice[0] for choice in field.get_choices(include_blank=False)],
["pea", "potato", "tomato"],
)
+
+ def test_count(self):
+ self.assertEqual(self.curry.ingredients.count(), 3)
+ self.assertEqual(self.tomato.recipes.count(), 1)
+
+ def test_exists(self):
+ self.assertTrue(self.curry.ingredients.exists())
+ self.assertTrue(self.tomato.recipes.exists())