From 4c35a173e881deaff17e5343181dcbc36177a4af Mon Sep 17 00:00:00 2001 From: Srinivas Reddy Thatiparthy Date: Fri, 25 May 2018 20:53:13 +0530 Subject: [PATCH] Fixed #29423 -- Documented Field.value_from_object(). --- docs/howto/custom-model-fields.txt | 4 ++-- docs/ref/models/fields.txt | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/howto/custom-model-fields.txt b/docs/howto/custom-model-fields.txt index 8ecfee8709..9d7e28b164 100644 --- a/docs/howto/custom-model-fields.txt +++ b/docs/howto/custom-model-fields.txt @@ -679,8 +679,8 @@ Converting field data for serialization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To customize how the values are serialized by a serializer, you can override -:meth:`~Field.value_to_string`. Using ``value_from_object()`` is the best way -to get the field's value prior to serialization. For example, since our +:meth:`~Field.value_to_string`. Using :meth:`~Field.value_from_object` is the +best way to get the field's value prior to serialization. For example, since ``HandField`` uses strings for its data storage anyway, we can reuse some existing conversion code:: diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index c696b770b3..5fc785fb18 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -1857,6 +1857,12 @@ Field API reference Besides saving to the database, the field also needs to know how to serialize its value: + .. method:: value_from_object(obj) + + Returns the field's value for the given model instance. + + This method is often used by :meth:`value_to_string`. + .. method:: value_to_string(obj) Converts ``obj`` to a string. Used to serialize the value of the field.