Added a test for QuerySet.update() with a ManyToManyField.
This commit is contained in:
parent
23c529a774
commit
a8c70abfdf
|
@ -46,3 +46,4 @@ class Foo(models.Model):
|
||||||
|
|
||||||
class Bar(models.Model):
|
class Bar(models.Model):
|
||||||
foo = models.ForeignKey(Foo, models.CASCADE, to_field='target')
|
foo = models.ForeignKey(Foo, models.CASCADE, to_field='target')
|
||||||
|
m2m_foo = models.ManyToManyField(Foo, related_name='m2m_foo')
|
||||||
|
|
|
@ -139,6 +139,15 @@ class AdvancedTests(TestCase):
|
||||||
bar_qs.update(foo=b_foo)
|
bar_qs.update(foo=b_foo)
|
||||||
self.assertEqual(bar_qs[0].foo_id, b_foo.target)
|
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):
|
def test_update_annotated_queryset(self):
|
||||||
"""
|
"""
|
||||||
Update of a queryset that's been annotated.
|
Update of a queryset that's been annotated.
|
||||||
|
|
Loading…
Reference in New Issue