-
Notifications
You must be signed in to change notification settings - Fork 16
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
Use form validation instead of triggering integrity error #643
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't working for me; when I try to update an existing summary.Visual without changing anything, I get a field form error.
I have a few ideas, I'm going to start working on this...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@munnsmunns ok, made some edits and I think this is a reasonable solution that works well - as a bonus - net negative code! Please give it a review to makes sure it works as expected for creates, updates, etc.
Create a generic helper method to check unique by assessment validation, when we don't include the assessment in a model form. This helper method is applied to numerous forms via a
clean_FOO
method.We initially tried including the assessment field in the form as a disabled hidden field, but ran into some issues with the value being hydrated correctly with a foreign key relation on updates.
In addition, expose
non_field_errors
in the reactDjangoForm
if errors are returned in validation.