Opened 17 years ago
Closed 17 years ago
#5153 closed (wontfix)
Allow "bypassing" validation in newforms
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Keywords: | feature | |
Cc: | cgrady@… | Triage Stage: | Design decision needed |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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 thecleaned_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 ifcommit=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.
Attachments (1)
Change History (6)
by , 17 years ago
Attachment: | ticket5153.diff added |
---|
comment:1 by , 17 years ago
Has patch: | set |
---|
comment:2 by , 17 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Design decision needed |
I'm not sure this is the best way to go about fixing your problem, but maybe I'm not really getting it. Perhaps bring this up in the Django Dev group?
comment:3 by , 17 years ago
Cc: | added |
---|
I don't really get it either... Why would you preview invalid data? Wouldn't you expect it to bounce back to the form until things are valid, then preview before the final save?
With that flow, this wouldn't be an issue at all, since the form would be valid and cleaned_data would remain :)
comment:4 by , 17 years ago
Keywords: | feature added |
---|
comment:5 by , 17 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Preview requirements should be handled by using FormPreview; in the meantime, I'm punting this as wontfix. If there's a valid used case, bring it up on django-developers.
Patch that adds
ensure_valid
option