summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-05-28 15:16:44 -0400
committerTim Graham <timograham@gmail.com>2016-05-28 16:06:06 -0400
commitf529d0cb5855db2dfc8d0d39850dbb4793bc75c2 (patch)
tree7be148495ef23a4825a522c2ca44908554d64c33 /tests
parentfc644076cdb45b8c227ff3041540f281a2c0b007 (diff)
[1.10.x] Refs #24227 -- Fixed crash of ManyToManyField.value_from_object() on unsaved model instances.
This behavior was removed in 67d984413c9540074e4fe6aa033081a35cf192bc but is needed to prevent a crash in formtools. Backport of a4c20ae85b40c49e28d1b2227208e4f00d7820df from master
Diffstat (limited to 'tests')
-rw-r--r--tests/model_fields/test_manytomanyfield.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/model_fields/test_manytomanyfield.py b/tests/model_fields/test_manytomanyfield.py
index f368c18403..3134a33197 100644
--- a/tests/model_fields/test_manytomanyfield.py
+++ b/tests/model_fields/test_manytomanyfield.py
@@ -6,6 +6,14 @@ from django.test.utils import isolate_apps
class ManyToManyFieldTests(SimpleTestCase):
+ @isolate_apps('model_fields')
+ def test_value_from_object_instance_without_pk(self):
+ class ManyToManyModel(models.Model):
+ m2m = models.ManyToManyField('self', models.CASCADE)
+
+ instance = ManyToManyModel()
+ self.assertEqual(instance._meta.get_field('m2m').value_from_object(instance), [])
+
def test_abstract_model_pending_operations(self):
"""
Many-to-many fields declared on abstract models should not add lazy