mirror of
https://github.com/django/django.git
synced 2025-07-22 20:55:17 +00:00
[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:
parent
c4ee93128f
commit
325dd0befe
6 changed files with 69 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue