mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
[1.10.x] Documented how to copy a OneToOneField.
Thanks Anton Gilgur for the report and review. Backport of 2f44fa7f069427e2da18a0f6cb2ffc29699f2ca3 from master
This commit is contained in:
parent
e1f93e2b1e
commit
0d019287ee
@ -993,6 +993,15 @@ entry::
|
||||
entry.save()
|
||||
entry.authors.set(old_authors)
|
||||
|
||||
For a ``OneToOneField``, you must duplicate the related object and assign it
|
||||
to the new object's field to avoid violating the one-to-one unique constraint.
|
||||
For example, assuming ``entry`` is already duplicated as above::
|
||||
|
||||
detail = EntryDetail.objects.all()[0]
|
||||
detail.pk = None
|
||||
detail.entry = entry
|
||||
detail.save()
|
||||
|
||||
.. _topics-db-queries-update:
|
||||
|
||||
Updating multiple objects at once
|
||||
|
Loading…
x
Reference in New Issue
Block a user