summaryrefslogtreecommitdiff
path: root/tests/update/tests.py
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-07-07 13:01:38 -0400
committerTim Graham <timograham@gmail.com>2017-07-08 07:40:45 -0400
commita8c70abfdf68fc841556b317a558c5dcf192b3a6 (patch)
tree1ef6f72bcc82ab98ad35a96742a8a6124afa263c /tests/update/tests.py
parent23c529a7747e62fe0de1a2dc98af7ce42c1c9d36 (diff)
Added a test for QuerySet.update() with a ManyToManyField.
Diffstat (limited to 'tests/update/tests.py')
-rw-r--r--tests/update/tests.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/update/tests.py b/tests/update/tests.py
index 55a8e24c6a..ba7ffd5c88 100644
--- a/tests/update/tests.py
+++ b/tests/update/tests.py
@@ -139,6 +139,15 @@ class AdvancedTests(TestCase):
bar_qs.update(foo=b_foo)
self.assertEqual(bar_qs[0].foo_id, b_foo.target)
+ def test_update_m2m_field(self):
+ msg = (
+ 'Cannot update model field '
+ '<django.db.models.fields.related.ManyToManyField: m2m_foo> '
+ '(only non-relations and foreign keys permitted).'
+ )
+ with self.assertRaisesMessage(FieldError, msg):
+ Bar.objects.update(m2m_foo='whatever')
+
def test_update_annotated_queryset(self):
"""
Update of a queryset that's been annotated.