summaryrefslogtreecommitdiff
path: root/django/forms/widgets.py
diff options
context:
space:
mode:
authorShubham singh <shubham1.singh15@gmail.com>2020-01-05 13:21:33 +0530
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-01-08 09:15:31 +0100
commitffcf1a8ebfbdc8e3afac84aed88d6ed29a57c72b (patch)
tree926c2b0ff48cb97bf5aba5a3fe2e12bff7a3b6c6 /django/forms/widgets.py
parent53d8646f799de7f92ab9defe9dc56c6125448102 (diff)
Fixed #31118 -- Made FileInput to avoid the required attribute when initial data exists.
Diffstat (limited to 'django/forms/widgets.py')
-rw-r--r--django/forms/widgets.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index 338d54d72f..40ac1d3162 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -387,6 +387,9 @@ class FileInput(Input):
def value_omitted_from_data(self, data, files, name):
return name not in files
+ def use_required_attribute(self, initial):
+ return super().use_required_attribute(initial) and not initial
+
FILE_INPUT_CONTRADICTION = object()
@@ -451,9 +454,6 @@ class ClearableFileInput(FileInput):
return False
return upload
- def use_required_attribute(self, initial):
- return super().use_required_attribute(initial) and not initial
-
def value_omitted_from_data(self, data, files, name):
return (
super().value_omitted_from_data(data, files, name) and