summaryrefslogtreecommitdiff
path: root/docs/howto
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-08-18 12:49:50 -0400
committerTim Graham <timograham@gmail.com>2014-08-18 12:54:24 -0400
commit955fdc8cdb0c1a98741687513980b64de8f20c75 (patch)
treeecbe4b685d5ab4129879bfe16c44626027093f75 /docs/howto
parentf5e8376288783554e4da398183dfa627c73401e5 (diff)
[1.6.x] Fixed #14638 -- Clarified model Field.to_python() docs.
Thanks Anubhav Joshi for the patch. Backport of b6aa60f425 from master
Diffstat (limited to 'docs/howto')
-rw-r--r--docs/howto/custom-model-fields.txt18
1 files changed, 9 insertions, 9 deletions
diff --git a/docs/howto/custom-model-fields.txt b/docs/howto/custom-model-fields.txt
index f81e58b468..2b41b0b08d 100644
--- a/docs/howto/custom-model-fields.txt
+++ b/docs/howto/custom-model-fields.txt
@@ -274,17 +274,17 @@ If you want your code to work on Python 2 & 3, you can use
class HandField(with_metaclass(models.SubfieldBase, models.Field)):
...
-This ensures that the :meth:`.to_python` method, documented below, will always
-be called when the attribute is initialized.
+This ensures that the :meth:`.to_python` method will always be called when the
+attribute is initialized.
-ModelForms and custom fields
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+``ModelForm``\s and custom fields
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-If you use :class:`~django.db.models.SubfieldBase`, :meth:`.to_python`
-will be called every time an instance of the field is assigned a
-value. This means that whenever a value may be assigned to the field,
-you need to ensure that it will be of the correct datatype, or that
-you handle any exceptions.
+If you use :class:`~django.db.models.SubfieldBase`, :meth:`.to_python` will be
+called every time an instance of the field is assigned a value (in addition to
+its usual call when retrieving the value from the database). This means that
+whenever a value may be assigned to the field, you need to ensure that it will
+be of the correct datatype, or that you handle any exceptions.
This is especially important if you use :doc:`ModelForms
</topics/forms/modelforms>`. When saving a ModelForm, Django will use