#16986: Model.clean cannot report errors on individual fields
-----------------------------+-------------------------------------
Reporter: davidfstr | Owner: davidfstr
Type: New feature | Status: new
Component: Forms | Version: SVN
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-----------------------------+-------------------------------------
Changes (by carljm):
* needs_better_patch: 0 => 1
Comment:
Replying to [comment:13 davidfstr]:
> Is there any futher action on my part that is preventing this ticket
from proceeding?
Nothing preventing, no. You always have the option of finding some other
community member to review the patch, try it out, and if it seems good to
them, mark it Ready For Checkin - that'll bump it higher on the commit
list. But really I just ran short of time the last month or so and never
got back to this.
I've done a review now and noticed some new things. I'm not particularly
concerned about r12402 - if there was an important reason to forbid this,
it should have been explicitly mentioned in that commit message. It seems
to me that it simply wasn't considered as a real use case. I am, however,
concerned about API consistency, and currently there are two ways this
patch breaks it:
1. If you can raise `ValidationError` with a dict from `Model.clean()` and
have `ModelForm` take that up into its error dict, you should be able to
do the same from `ModelForm.clean()` or `Form.clean()`; in other words,
regular form validation and model validation should behave the same in
terms of how `ValidationError` can be used. Having it possible to use a
dict from the one clean method and not the others is arbitrary and
confusing.
2. You can instantiate `ValidationError` with either a single message, or
a list of messages. If we're going to add instantiation with a dictionary
as a documented API (which seems fine to me), I think the values in that
dictionary should similarly be allowed to be either a single message or a
list of messages, not required to be a list.
--
Ticket URL: <https://code.djangoproject.com/ticket/16986#comment:14>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.