Fixed #33830 -- Fixed VariableDoesNotExist when rendering ClearableFileInput.

This commit is contained in:
Neeraj Kumar 2022-08-24 14:35:01 +05:30 committed by Mariusz Felisiak
parent 6f49b7b69b
commit 9942f3fb49
2 changed files with 11 additions and 0 deletions

View File

@ -481,6 +481,7 @@ class ClearableFileInput(FileInput):
"clear_checkbox_label": self.clear_checkbox_label, "clear_checkbox_label": self.clear_checkbox_label,
} }
) )
context["widget"]["attrs"].setdefault("disabled", False)
return context return context
def value_from_datadict(self, data, files, name): def value_from_datadict(self, data, files, name):

View File

@ -110,6 +110,16 @@ class ClearableFileInputTest(WidgetTest):
), ),
) )
def test_render_no_disabled(self):
class TestForm(Form):
clearable_file = FileField(
widget=self.widget, initial=FakeFieldFile(), required=False
)
form = TestForm()
with self.assertNoLogs("django.template", "DEBUG"):
form.render()
def test_render_as_subwidget(self): def test_render_as_subwidget(self):
"""A ClearableFileInput as a subwidget of MultiWidget.""" """A ClearableFileInput as a subwidget of MultiWidget."""
widget = MultiWidget(widgets=(self.widget,)) widget = MultiWidget(widgets=(self.widget,))