Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix input: rendering ClearableFileInput (django 4.2) #35

Open
corentinbettiol opened this issue Feb 6, 2024 · 0 comments
Open

Fix input: rendering ClearableFileInput (django 4.2) #35

corentinbettiol opened this issue Feb 6, 2024 · 0 comments

Comments

@corentinbettiol
Copy link

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()
@corentinbettiol corentinbettiol changed the title Fix input: rendering ClearableFileInput Fix input: rendering ClearableFileInput (django 4.2) Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant