summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-02-03 11:11:39 -0500
committerTim Graham <timograham@gmail.com>2017-02-06 20:55:47 -0500
commit2b17e4770bc02b4bf6864b21587feae815768613 (patch)
tree58d262abffcd4a1056beb5e2ecbfaf44a35804e7 /django/forms
parentf14899412d2fa779e3f8dbfa6e63b8a6a7a765a5 (diff)
[1.11.x] Fixed #27805 -- Fixed ClearableFileInput's "Clear" checkbox on model fields with a default.
Backport of 4353640ea9495d58fabd0357253b82de3b069408 from master
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/widgets.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index 594b578431..aca599ff9a 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -437,6 +437,12 @@ class ClearableFileInput(FileInput):
def use_required_attribute(self, initial):
return super(ClearableFileInput, self).use_required_attribute(initial) and not initial
+ def value_omitted_from_data(self, data, files, name):
+ return (
+ super(ClearableFileInput, self).value_omitted_from_data(data, files, name) and
+ self.clear_checkbox_name(name) not in data
+ )
+
class Textarea(Widget):
template_name = 'django/forms/widgets/textarea.html'