Fixed #33830 -- Fixed VariableDoesNotExist when rendering ClearableFileInput.
This commit is contained in:
parent
6f49b7b69b
commit
9942f3fb49
|
@ -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):
|
||||||
|
|
|
@ -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,))
|
||||||
|
|
Loading…
Reference in New Issue