mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #25550 -- Deprecated direct assignment to the reverse side of a related set.
This commit is contained in:
parent
0b5d32faca
commit
9c5e272860
37 changed files with 194 additions and 130 deletions
|
@ -74,7 +74,7 @@ class M2MRegressionTests(TestCase):
|
|||
t2 = Tag.objects.create(name='t2')
|
||||
|
||||
c1 = TagCollection.objects.create(name='c1')
|
||||
c1.tags = [t1, t2]
|
||||
c1.tags.set([t1, t2])
|
||||
c1 = TagCollection.objects.get(name='c1')
|
||||
|
||||
self.assertQuerysetEqual(c1.tags.all(), ["<Tag: t1>", "<Tag: t2>"], ordered=False)
|
||||
|
@ -104,10 +104,10 @@ class M2MRegressionTests(TestCase):
|
|||
t1 = Tag.objects.create(name='t1')
|
||||
t2 = Tag.objects.create(name='t2')
|
||||
c1 = TagCollection.objects.create(name='c1')
|
||||
c1.tags = [t1, t2]
|
||||
c1.tags.set([t1, t2])
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
c1.tags = 7
|
||||
c1.tags.set(7)
|
||||
|
||||
c1.refresh_from_db()
|
||||
self.assertQuerysetEqual(c1.tags.order_by('name'), ["<Tag: t1>", "<Tag: t2>"])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue