Loading django/forms/widgets.py +7 −3 Original line number Diff line number Diff line Loading @@ -452,9 +452,13 @@ class NullBooleanSelect(Select): False: False}.get(value, None) def _has_changed(self, initial, data): # Sometimes data or initial could be None or u'' which should be the # same thing as False. return bool(initial) != bool(data) # For a NullBooleanSelect, None (unknown) and False (No) # are not the same if initial is not None: initial = bool(initial) if data is not None: data = bool(data) return initial != data class SelectMultiple(Select): def render(self, name, value, attrs=None, choices=()): Loading tests/regressiontests/forms/widgets.py +14 −0 Original line number Diff line number Diff line Loading @@ -532,6 +532,20 @@ Choices can be nested one level in order to create HTML optgroups: <option value="2">Yes</option> <option value="3" selected="selected">No</option> </select> >>> w._has_changed(False, None) True >>> w._has_changed(None, False) True >>> w._has_changed(None, None) False >>> w._has_changed(False, False) False >>> w._has_changed(True, False) True >>> w._has_changed(True, None) True >>> w._has_changed(True, True) False """ + \ r""" # [This concatenation is to keep the string below the jython's 32K limit]. Loading Loading
django/forms/widgets.py +7 −3 Original line number Diff line number Diff line Loading @@ -452,9 +452,13 @@ class NullBooleanSelect(Select): False: False}.get(value, None) def _has_changed(self, initial, data): # Sometimes data or initial could be None or u'' which should be the # same thing as False. return bool(initial) != bool(data) # For a NullBooleanSelect, None (unknown) and False (No) # are not the same if initial is not None: initial = bool(initial) if data is not None: data = bool(data) return initial != data class SelectMultiple(Select): def render(self, name, value, attrs=None, choices=()): Loading
tests/regressiontests/forms/widgets.py +14 −0 Original line number Diff line number Diff line Loading @@ -532,6 +532,20 @@ Choices can be nested one level in order to create HTML optgroups: <option value="2">Yes</option> <option value="3" selected="selected">No</option> </select> >>> w._has_changed(False, None) True >>> w._has_changed(None, False) True >>> w._has_changed(None, None) False >>> w._has_changed(False, False) False >>> w._has_changed(True, False) True >>> w._has_changed(True, None) True >>> w._has_changed(True, True) False """ + \ r""" # [This concatenation is to keep the string below the jython's 32K limit]. Loading