#12698: ValidationError requires dict() to function properly ------------------------------------------------+--------------------------- Reporter: orokusaki | Owner: nobody Status: new | Milestone: Component: Database layer (models, ORM) | Version: SVN Keywords: core.exceptions, core.forms.models | Stage: Unreviewed Has_patch: 0 | ------------------------------------------------+--------------------------- In django.core.exceptions on line 45, you see the code is checking if the message passed in is a dict. If not, it sets self.messages = [message]. Then on line 67 update_error_dict() appears to do what's needed in this case of passing in just a string in, like: ValidationError('This is some model validation error in some_model_instance.clean()').
The exception comes at django.forms.models.py on line 320 in _clean_form() (I've commented the code below but not added any code suggestions because I'm not the best developer). {{{ def _clean_form(self): """ Runs the instance's clean method, then the form's. This is becuase the form will run validate_unique() by default, and we should run the model's clean method first. """ try: self.instance.clean() except ValidationError, e: # Here it assumes that the exception raised has the attribute 'message_dict', # but since the errors in the __init__ were not set using (possibly) update_error_dict(), # there is just a list in e.messages. self._update_errors(e.message_dict) super(BaseModelForm, self)._clean_form() }}} -- Ticket URL: <http://code.djangoproject.com/ticket/12698> 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 django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.