From 4cef9a09f9b0d89abf323a1cf8b9e8354e316c18 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 19 Oct 2012 06:52:30 -0400 Subject: [PATCH] Fixed #17388 - Noted in the custom model field docs that field methods need to handle None if the field may be null. --- docs/howto/custom-model-fields.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/howto/custom-model-fields.txt b/docs/howto/custom-model-fields.txt index 9ff06479c6..1e9d5d8701 100644 --- a/docs/howto/custom-model-fields.txt +++ b/docs/howto/custom-model-fields.txt @@ -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 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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~