mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Refs #25550 -- Removed support for direct assignment to the reverse side of a related set.
This commit is contained in:
parent
e0910dcc92
commit
ed251246cc
5 changed files with 17 additions and 74 deletions
|
@ -177,26 +177,3 @@ Related objects reference
|
|||
.. versionchanged:: 1.11
|
||||
|
||||
The clearing of the prefetched cache described above was added.
|
||||
|
||||
Direct Assignment
|
||||
=================
|
||||
|
||||
A related object set can be replaced in bulk with one operation by assigning a
|
||||
new iterable of objects to it::
|
||||
|
||||
>>> new_list = [obj1, obj2, obj3]
|
||||
>>> e.related_set = new_list
|
||||
|
||||
If the foreign key relationship has ``null=True``, then the related manager
|
||||
will first disassociate any existing objects in the related set before adding
|
||||
the contents of ``new_list``. Otherwise the objects in ``new_list`` will be
|
||||
added to the existing related object set.
|
||||
|
||||
.. deprecated:: 1.10
|
||||
|
||||
Direct assignment is deprecated in favor of the
|
||||
:meth:`~django.db.models.fields.related.RelatedManager.set` method::
|
||||
|
||||
>>> e.related_set.set([obj1, obj2, obj3])
|
||||
|
||||
This prevents confusion about an assignment resulting in an implicit save.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue