1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #25550 -- Deprecated direct assignment to the reverse side of a related set.

This commit is contained in:
Tim Graham
2015-10-08 17:17:10 -04:00
parent 0b5d32faca
commit 9c5e272860
37 changed files with 194 additions and 130 deletions

View File

@@ -269,6 +269,21 @@ Miscellaneous
Features deprecated in 1.10
===========================
Direct assignment to a reverse foreign key or many-to-many relation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Instead of assigning related objects using direct assignment::
>>> new_list = [obj1, obj2, obj3]
>>> e.related_set = new_list
Use the :meth:`~django.db.models.fields.related.RelatedManager.set` method
added in Django 1.9::
>>> e.related_set.set([obj1, obj2, obj3])
This prevents confusion about an assignment resulting in an implicit save.
Miscellaneous
~~~~~~~~~~~~~