Opened 20 months ago

Closed 20 months ago

Last modified 20 months ago

#22785 closed Cleanup/optimization (needsinfo)

NamedUrlWizard errors are silently discarded when overriding render_done()

Reported by: danielsamuels Owned by: nobody
Component: contrib.formtools Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


See this line of code:

I was hoping to be able to override the render_done method and raise a ValidationError for some fields and have the Wizard show those errors on the relevant step, but it appears that the Wizard simply performs a redirect which means you can't actually do any additional validation (this may be a separate issue though). Either way, I noticed that although the form object (with errors added) is passed to render_revalidation_failure, it doesn't actually get used, unlike render_revalidation_failure used in the base WizardView.

Change History (9)

comment:1 Changed 20 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to needsinfo
  • Status changed from new to closed

How should it be used? The render_revalidation_failure() method needs to have the same signature across all subclasses regardless of whether or not the subclasses uses them all.

comment:2 Changed 20 months ago by danielsamuels

Sorry, I chose a terrible title for this ticket. The main issue is that for any FormWizard which isn't a NamedUrlWizardView you're able to raise ValidationErrors and have those displayed on the form which failed. When a form fails validation on a NamedUrlWizard you just get redirected back to the form and any ValidationErrors which were raised get silently discarded. This issue only really affects people who are overriding render_done, raising a ValidationError and returning render_revalidation_failure().

comment:3 Changed 20 months ago by timo

  • Resolution needsinfo deleted
  • Status changed from closed to new
  • Summary changed from render_revalidation_failure in NamedUrlWizardView has unused parameters to NamedUrlWizard errors are silently discarded when overriding render_done()

Okay, I'm not too familiar with the code. Can you propose a fix?

comment:4 Changed 20 months ago by anonymous

The way I fixed it in my project was to push the ValidationErrors into the messages framework and then pull them out on the other side, not sure if that's a valid solution for Django itself though.

comment:5 Changed 20 months ago by timo

I don't think so -- we wouldn't want to add coupling between the two contrib apps.

comment:6 Changed 20 months ago by timo

  • Resolution set to needsinfo
  • Status changed from new to closed

Closing as "needs info" absent a proposal for how this should be addressed -- if someone has a suggestion, please reopen.

comment:7 Changed 20 months ago by thomasrumbold@…

I don't mean to be unhelpful here - but as I understand it, this existing issue has been closed because there hasn't been a proposal to fix it within 12 days of it being submitted. That doesn't change the fact that it exists. Surely the default would be to leave it open until further notice and potentially, someone can contribute?

comment:8 Changed 20 months ago by timo

Yes, and I don't mean to be aggressive in closing it. I haven't studied the issue, but I am not sure it is possible to fix in a general fashion since the solution Daniel came up with involved using messages. We try to keep open tickets actionable, so I would rather keep this closed until someone decides it's possible to fix rather than keeping an open ticket for something where no clear path of action exists. Are the two wizards intended to work in the same way or is this simply a limitation of NamedUrlWizardView?

comment:9 Changed 20 months ago by danielsamuels

As far as I'm aware all of the Wizards except NamedUrlWizardView handle ValidationErrors correctly - because they re-render the form directly instead of redirecting like NamedUrlWizardView does.

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