#15616: django.core.exceptions.ValidationError is poorly implemented and documented ----------------------------------------+--------------------------- Reporter: tomevans223 | Owner: nobody Status: new | Milestone: Component: Core framework | Version: SVN Keywords: validation validationerror | Triage Stage: Unreviewed Has patch: 0 | ----------------------------------------+--------------------------- django.core.exceptions.ValidationError has a horrific interface. It's publicly accessible attributes differ depending upon how the object is created, as do the pre/post conditions for it's publicly accessible methods.
If constructed with a dictionary of error messages, then it gets an attribute 'message_dict'. If constructed with a string, or a list of strings, then it gets an attribute 'messages'. The documentation on Model.clean() talks about ValidationError, but does not mention this at all, and instructs the user to look at messages_dict. [1] If constructed with a dictionary of error messages, then the method update_error_dict(self, error_dict) will happily accept error_dict=None - it checks for and handles this condition. If constructed with a string or list, then not supplying error_dict is an error. This sort of inconsistent behaviour is hard to explain. At the least, this behaviour should be documented clearly, but ideally the interface should be consistent, regardless of how it is constructed. [1] http://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.clean -- Ticket URL: <http://code.djangoproject.com/ticket/15616> Django <http://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.
