﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
12698	ValidationError bug when passing a string message argument in model validation	Oroku Saki	nobody	"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()
}}}
"	Uncategorized	closed	Database layer (models, ORM)	dev	Normal	fixed	core.exceptions, core.forms.models, model validation		Accepted	1	0	1	0	0	0
