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

Check for cleared file value #454

Merged
merged 2 commits into from Sep 15, 2017
Merged

Check for cleared file value #454

merged 2 commits into from Sep 15, 2017

Conversation

stefanw
Copy link
Contributor

@stefanw stefanw commented Apr 11, 2017

When clearing a file in the Django Admin by checking the "Clear" checkbox, you get the following error on this line:

AttributeError: 'bool' object has no attribute '_committed'

A file field value maybe False when cleared via ClearableFileInput. This PR checks the value before accessing _committed.

A file field maybe False when cleared via ClearableFormInput
Copy link
Owner

@SmileyChris SmileyChris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and thanks for the patch! It'd be nice to have some tests to show a case where this actually fixes something ;)

@stefanw
Copy link
Contributor Author

stefanw commented Aug 9, 2017

I added a test, but I'm not entirely clear if this is the best way to test it.

However, I noticed that Django itself has the same check in its own pre_save method of FileField.

@jrief jrief merged commit 16f12cb into SmileyChris:master Sep 15, 2017
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

Successfully merging this pull request may close these issues.

None yet

3 participants