#16986: Model.clean cannot report errors on individual fields
-----------------------------+------------------------------------
     Reporter:  davidfstr    |                    Owner:  nobody
         Type:  New feature  |                   Status:  new
    Component:  Forms        |                  Version:  SVN
     Severity:  Normal       |               Resolution:
     Keywords:               |             Triage Stage:  Accepted
    Has patch:  1            |      Needs documentation:  1
  Needs tests:  1            |  Patch needs improvement:  1
Easy pickings:  0            |                    UI/UX:  0
-----------------------------+------------------------------------

Comment (by carljm):

 Replying to [comment:3 davidfstr]:
 > Regarding backward-compatibility, there is unfortunately very
 
[https://docs.djangoproject.com/en/dev/ref/exceptions/#django.core.exceptions.ValidationError
 little documentation for ValidationError], so I must assume any advanced
 users are depending on the exact implementation.
 >
 > So I've reverted to your implementation approach (which has minimal
 impact) and updated the patch. I recognize it still needs a new test case
 and documentation changes.

 Actually, the fact that the internals of `ValidationError` are not
 documented means that they are considered an implementation detail, and
 can be changed without regard to backward-compatibility; only the
 documented interface (which in this case I think is just instantiation
 with a message string) need remain compatible. Anyone using undocumented
 internal details can update their code if needed.

 That said, I'm not sure initializing message_dict the way you suggest is
 correct. `ValidationError` without a dict can be used from inside a
 clean_field method to raise errors specific to that field, in which case
 having a message_dict property auto-initialized using `__all__` seems
 semantically wrong. Essentially `ValidationError` itself can in some cases
 be agnostic as to which field its errors belong to, and that is determined
 by context.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16986#comment:4>
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.

Reply via email to