Allow "bypassing" validation in newforms
|Reported by:||Christopher Lenz <cmlenz@…>||Owned by:||nobody|
|Cc:||cgrady@…||Triage Stage:||Design decision needed|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||yes||Patch needs improvement:||no|
I'm trying to generate a preview page based on a temporary model that should be populated from a form. The idea here is to be able to reuse the same template code as is used for the real view of the model, so simply basing the preview on the raw form data won't cut it.
There are actual two problems here:
- There seems to be no way whatsoever to trick newforms into keeping the cleaned_data even when a validation error is encountered. It's stubbornly delete the cleaned_data attribute.
- newforms.models.save_instance checks whether the form has errors, so it won't allow me to populate the model instance from the form, even if commit=False.
For (1), I think there should be an option to not discard the cleaned_data on errors. For (2), there should be an option to ignore validation errors. I'm attaching a patch that does this.
Change History (6)
Changed 9 years ago by Christopher Lenz <cmlenz@…>
comment:1 Changed 9 years ago by Christopher Lenz <cmlenz@…>
- Has patch set
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:2 Changed 8 years ago by SmileyChris
- Needs tests set
- Triage Stage changed from Unreviewed to Design decision needed