summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/db/queries.txt15
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt
index eb5b323abb..bd092f524b 100644
--- a/docs/topics/db/queries.txt
+++ b/docs/topics/db/queries.txt
@@ -1590,6 +1590,21 @@ For example, assuming ``entry`` is already duplicated as above::
detail.entry = entry
detail.save()
+Note that it is not possible to copy instances of models with deferred fields
+using this pattern unless values are assigned to them:
+
+.. code-block:: pycon
+
+ >>> blog = Blog.objects.defer("name")[0]
+ >>> blog.pk = None
+ >>> blog._state.adding = True
+ >>> blog.save()
+ Traceback (most recent call last):
+ ...
+ AttributeError: Cannot retrieve deferred field 'name' from an unsaved model.
+ >>> blog.name = "Another Blog"
+ >>> blog.save()
+
.. _topics-db-queries-update:
Updating multiple objects at once