diff options
| author | Shubham singh <shubham1.singh15@gmail.com> | 2020-01-05 13:21:33 +0530 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-01-08 09:15:31 +0100 |
| commit | ffcf1a8ebfbdc8e3afac84aed88d6ed29a57c72b (patch) | |
| tree | 926c2b0ff48cb97bf5aba5a3fe2e12bff7a3b6c6 /django/forms/widgets.py | |
| parent | 53d8646f799de7f92ab9defe9dc56c6125448102 (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.py | 6 |
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 |
