Opened 5 years ago

Closed 5 years ago

#30861 closed New feature (duplicate)

Support for ValidationWarning

Reported by: Dylan Young Owned by: nobody
Component: Forms Version: 2.2
Severity: Normal Keywords: validation
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: yes

Description

A ValidationWarning would work like a ValidationError, except that they wouldn't prevent form save and would be able to substitute an alternate value in the form to address the warning.

I'm happy to implement if we can get the go-ahead here.

This is one of the areas of missing support in Django that has plagued us since 1.4.

Hacking around this is painful. The only way that I know of to achieve the desired functionality, say when extending an existing model field with a new clean method, is by subclassing both the widget (to transform the output) and the field (to raise the ValidationError / send the message... Moreover, if going the message route, we also need access to the request!!!). This is just plain silliness.

Probably it would be useful to be able to control whether it saves or not, defaulting to save=True since it is a "warning". Alternatively, allowing ValidationError to transform the input value would likely be more semantic than a save kwarg to ValidationWarning. A level kwarg might be valuable too (to set the default message level of the resulting message).

Change History (1)

comment:1 by Simon Charette, 5 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #23.

This should be brought up on the mailing list if you think the decision of closing #23 should be revisited.

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