From ffcf1a8ebfbdc8e3afac84aed88d6ed29a57c72b Mon Sep 17 00:00:00 2001 From: Shubham singh Date: Sun, 5 Jan 2020 13:21:33 +0530 Subject: Fixed #31118 -- Made FileInput to avoid the required attribute when initial data exists. --- django/forms/widgets.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'django/forms/widgets.py') 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 -- cgit v1.3