mirror of https://github.com/django/django.git
Simplified the newforms error_messages setting code from [6625]
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6785 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
f27365e5bd
commit
394807866d
|
@ -83,21 +83,15 @@ class Field(object):
|
||||||
self.creation_counter = Field.creation_counter
|
self.creation_counter = Field.creation_counter
|
||||||
Field.creation_counter += 1
|
Field.creation_counter += 1
|
||||||
|
|
||||||
self.error_messages = self._build_error_messages(error_messages)
|
def set_class_error_messages(messages, klass):
|
||||||
|
|
||||||
def _build_error_messages(self, extra_error_messages):
|
|
||||||
error_messages = {}
|
|
||||||
|
|
||||||
def get_default_error_messages(klass):
|
|
||||||
for base_class in klass.__bases__:
|
for base_class in klass.__bases__:
|
||||||
get_default_error_messages(base_class)
|
set_class_error_messages(messages, base_class)
|
||||||
if hasattr(klass, 'default_error_messages'):
|
messages.update(getattr(klass, 'default_error_messages', {}))
|
||||||
error_messages.update(klass.default_error_messages)
|
|
||||||
|
|
||||||
get_default_error_messages(self.__class__)
|
messages = {}
|
||||||
if extra_error_messages:
|
set_class_error_messages(messages, self.__class__)
|
||||||
error_messages.update(extra_error_messages)
|
messages.update(error_messages or {})
|
||||||
return error_messages
|
self.error_messages = messages
|
||||||
|
|
||||||
def clean(self, value):
|
def clean(self, value):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue