summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-06-21 13:46:22 -0400
committerTim Graham <timograham@gmail.com>2016-06-21 15:25:16 -0400
commit45a650777e4674bc540c3bf4b3108409f0e1f98a (patch)
tree57fd62fcbc5788fe87b22d9ecb77aa9abdeb8011 /docs
parentc464cf88ff5eeabea0109daee35dba8a32f8644d (diff)
[1.10.x] Fixed #26787 -- Documented deleting and reloading of model instance fields.
Thanks Julien Hartmann for the report. Backport of 20d1cb33c2ec1242e16c49deb88e8c70517b2d1a from master
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/instances.txt12
-rw-r--r--docs/releases/1.10.txt3
2 files changed, 15 insertions, 0 deletions
diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt
index 517c29e867..101e1d94a0 100644
--- a/docs/ref/models/instances.txt
+++ b/docs/ref/models/instances.txt
@@ -128,6 +128,18 @@ in the ``from_db()`` method.
Refreshing objects from database
================================
+If you delete a field from a model instance, accessing it again reloads the
+value from the database::
+
+ >>> obj = MyModel.objects.first()
+ >>> del obj.field
+ >>> obj.field # Loads the field from the database
+
+.. versionchanged:: 1.10
+
+ In older versions, accessing a deleted field raised ``AttributeError``
+ instead of reloading it.
+
.. method:: Model.refresh_from_db(using=None, fields=None)
If you need to reload a model's values from the database, you can use the
diff --git a/docs/releases/1.10.txt b/docs/releases/1.10.txt
index 8dd97e3da8..752684e3fa 100644
--- a/docs/releases/1.10.txt
+++ b/docs/releases/1.10.txt
@@ -884,6 +884,9 @@ Miscellaneous
* The ``_base_manager`` and ``_default_manager`` attributes are removed from
model instances. They remain accessible on the model class.
+* Accessing a deleted field on a model instance, e.g. after ``del obj.field``,
+ reloads the field's value instead of raising ``AttributeError``.
+
.. _deprecated-features-1.10:
Features deprecated in 1.10