django-file-resubmit
django-file-resubmit copied to clipboard
Fix input: rendering ClearableFileInput (django 4.2)
Starting with django 4.2 we can't see the file anymore on the error page, because a fix was implemented for an eleven years old ticket and it broke the FileField
bound_data
function, who's called when rendering the widget.
So here's our fix (found this after a wild ride, you just need to redefine the function and to return the right data):
class FixedClearableFileInput(forms.FileField):
def bound_data(self, data, initial):
return data
# ...
class OurSuperForm(SomeOtherForm):
logo = FixedClearableFileInput()