summaryrefslogtreecommitdiff
path: root/docs/howto
diff options
context:
space:
mode:
authorThomas Stephenson <ovangle@gmail.com>2015-04-26 16:30:46 +1000
committerTim Graham <timograham@gmail.com>2015-07-14 09:13:22 -0400
commit035b0fa60da2e758d0ab7f9d04ef93cdb73c981f (patch)
tree4effeaa7efc8c9ac62bd32817daa3c5da750b7bf /docs/howto
parent0ffa3943fbd100e7de7b1ddbfd301ddc52b57410 (diff)
Fixed #24716 -- Deprecated Field._get_val_from_obj()
The method duplicates the functionality of Field.value_from_object() and has the additional downside of being a privately named public API method.
Diffstat (limited to 'docs/howto')
-rw-r--r--docs/howto/custom-model-fields.txt9
1 files changed, 5 insertions, 4 deletions
diff --git a/docs/howto/custom-model-fields.txt b/docs/howto/custom-model-fields.txt
index 95c1cd68ab..c0cde0e99b 100644
--- a/docs/howto/custom-model-fields.txt
+++ b/docs/howto/custom-model-fields.txt
@@ -705,15 +705,16 @@ Converting field data for serialization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To customize how the values are serialized by a serializer, you can override
-:meth:`~Field.value_to_string`. Calling ``Field._get_val_from_obj(obj)`` is the
-best way to get the value serialized. For example, since our ``HandField`` uses
-strings for its data storage anyway, we can reuse some existing conversion code::
+: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
+``HandField`` uses strings for its data storage anyway, we can reuse some
+existing conversion code::
class HandField(models.Field):
# ...
def value_to_string(self, obj):
- value = self._get_val_from_obj(obj)
+ value = self.value_from_object(obj)
return self.get_prep_value(value)
Some general advice