Fixed #16192 -- Made unique error messages in ModelForm customizable.

Overriding the error messages now works for both unique fields, unique_together
and unique_for_date.

This patch changed the overriding logic to allow customizing NON_FIELD_ERRORS
since previously only fields' errors were customizable.

Refs #20199.

Thanks leahculver for the suggestion.
This commit is contained in:
Loic Bistuer 2014-02-04 01:31:27 +07:00 committed by Tim Graham
parent 65131911db
commit 8847a0c601
11 changed files with 142 additions and 34 deletions

View file

@ -124,6 +124,15 @@ ValidationError
:ref:`Model Field Validation <validating-objects>` and the
:doc:`Validator Reference </ref/validators>`.
NON_FIELD_ERRORS
~~~~~~~~~~~~~~~~
.. data:: NON_FIELD_ERRORS
``ValidationError``\s that don't belong to a particular field in a form
or model are classified as ``NON_FIELD_ERRORS``. This constant is used
as a key in dictonaries that otherwise map fields to their respective
list of errors.
.. currentmodule:: django.core.urlresolvers
URL Resolver exceptions