[1.10.x] Fixed #27039 -- Fixed empty data fallback to model field default in model forms.

Backport of 4bc6b93994 from master
This commit is contained in:
Tim Graham 2016-08-11 15:18:48 -04:00
parent c4ee93128f
commit 325dd0befe
6 changed files with 69 additions and 2 deletions

View file

@ -480,6 +480,10 @@ def boolean_check(v):
class CheckboxInput(Widget):
# Don't use model field defaults for fields that aren't in POST data,
# because checkboxes don't appear in POST data if not checked.
dont_use_model_field_default_for_empty_data = True
def __init__(self, attrs=None, check_test=None):
super(CheckboxInput, self).__init__(attrs)
# check_test is a callable that takes a value and returns True