Opened 17 years ago

Closed 17 years ago

#5153 closed (wontfix)

Allow "bypassing" validation in newforms

Reported by: Christopher Lenz <cmlenz@…> 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:

  1. 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.
  2. 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.

Attachments (1)

ticket5153.diff (2.5 KB ) - added by Christopher Lenz <cmlenz@…> 17 years ago.
Patch that adds ensure_valid option

Download all attachments as: .zip

Change History (6)

by Christopher Lenz <cmlenz@…>, 17 years ago

Attachment: ticket5153.diff added

Patch that adds ensure_valid option

comment:1 by Christopher Lenz <cmlenz@…>, 17 years ago

Has patch: set

comment:2 by Chris Beaven, 17 years ago

Needs tests: set
Triage Stage: UnreviewedDesign 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 Collin Grady <cgrady@…>, 17 years ago

Cc: cgrady@… 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 Philippe Raoult, 17 years ago

Keywords: feature added

comment:5 by James Bennett, 17 years ago

Resolution: wontfix
Status: newclosed

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.

Note: See TracTickets for help on using tickets.
Back to Top