mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +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
|
@ -94,7 +94,7 @@ class ManyToOneNullTests(TestCase):
|
|||
# Use descriptor assignment to allocate ForeignKey. Null is legal, so
|
||||
# existing members of the set that are not in the assignment set are
|
||||
# set to null.
|
||||
self.r2.article_set = [self.a2, self.a3]
|
||||
self.r2.article_set.set([self.a2, self.a3])
|
||||
self.assertQuerysetEqual(self.r2.article_set.all(),
|
||||
['<Article: Second>', '<Article: Third>'])
|
||||
# Clear the rest of the set
|
||||
|
@ -106,11 +106,11 @@ class ManyToOneNullTests(TestCase):
|
|||
def test_assign_with_queryset(self):
|
||||
# Ensure that querysets used in reverse FK assignments are pre-evaluated
|
||||
# so their value isn't affected by the clearing operation in
|
||||
# ReverseManyToOneDescriptor.__set__. Refs #19816.
|
||||
self.r2.article_set = [self.a2, self.a3]
|
||||
# RelatedManager.set() (#19816).
|
||||
self.r2.article_set.set([self.a2, self.a3])
|
||||
|
||||
qs = self.r2.article_set.filter(headline="Second")
|
||||
self.r2.article_set = qs
|
||||
self.r2.article_set.set(qs)
|
||||
|
||||
self.assertEqual(1, self.r2.article_set.count())
|
||||
self.assertEqual(1, qs.count())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue