Kaydet (Commit) 2f44fa7f authored tarafından Tim Graham's avatar Tim Graham

Documented how to copy a OneToOneField.

Thanks Anton Gilgur for the report and review.
üst 8dac9890
......@@ -985,6 +985,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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment