#16423: ModelForm._post_clean() does not respect Model.clean() ValidationErrors that possess a message_dict, rather than a list of messages -----------------------------------+---------------------------- Reporter: robboyle | Owner: nobody Type: Cleanup/optimization | Status: new Milestone: | Component: Forms Version: 1.3 | Severity: Normal Keywords: modelform, validation | Triage Stage: Unreviewed Has patch: 0 | Easy pickings: 0 UI/UX: 0 | -----------------------------------+---------------------------- When a ModelForm runs it's model-level validation, it anticipates the Model's clean_fields() method raising a ValidationError with the message_dict property set. This let's the ModelForm associate the Model's Field validation errors with the ModelForm fields.
However, when the ModelForm then calls the Model's clean() method, it ignores the message_dict property if the ValidationError raised by clean() has it set. Instead, it always creates a new dictionary, associating all validation messages with the NON_FIELD_ERRORS key. It would be nice if _post_clean() checked if Model.clean() was raising a ValidationError with a message_dict, and if so updated the errors with that dict, rather than blindly creating a new one. That way, the Model.clean() method could associate errors with a particular field, return a ValidationError with message_dict set, and this association would be perserved by the ModelForm. Being able to have a form's clean method associate errors with a particular field is very handy. Being able to do this at the model level and then have model forms take advantage of it would bring model forms more on par with regular forms. -- Ticket URL: <https://code.djangoproject.com/ticket/16423> 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 django-updates@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.