Fixed #17388 - Noted in the custom model field docs that field methods need to handle None if the field may be null.

This commit is contained in:
Tim Graham 2012-10-19 06:52:30 -04:00
parent 0b908b92a2
commit 4cef9a09f9
1 changed files with 7 additions and 0 deletions

View File

@ -448,6 +448,13 @@ called when it is created, you should be using `The SubfieldBase metaclass`_
mentioned earlier. Otherwise :meth:`.to_python` won't be called mentioned earlier. Otherwise :meth:`.to_python` won't be called
automatically. automatically.
.. warning::
If your custom field allows ``null=True``, any field method that takes
``value`` as an argument, like :meth:`~Field.to_python` and
:meth:`~Field.get_prep_value`, should handle the case when ``value`` is
``None``.
Converting Python objects to query values Converting Python objects to query values
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~