Conversation
| except BinderFieldTypeError: | ||
| if not validation_errors: | ||
| raise | ||
|
|
There was a problem hiding this comment.
So I see 2 issues with this approach:
- This now works for all
BinderFieldTypeErrors, not just the ones that are caused by the save of another model not working. In the other cases aBinderFieldTypeErrorshould be more important than a validation error. - If both the related model and the main model have validation errors this will now ignore the validation errors on the main model.
I would suggest to instead pass an extra argument to _store that provides which models have failed to save and then prevent the BinderFieldTypeError from being raised when the value refers to one of these models.
There was a problem hiding this comment.
Managed to create test for the second bullet, but I have a problem in generating a test for the first bullet point related to BinderFieldTypeError. Can you give some tips?
After writing failing tests i will start with refactor and try to use _store.
There was a problem hiding this comment.
So a BinderFieldTypeError should occur when the value that you are trying to save does not match the type of the field, so for example trying to save a string into an integer field. Do note that django does try to 'fix' values. So for example the other way around (an integer to a string field) it would just turn the integer into a string.
No description provided.