1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #12512. Changed ModelForm to stop performing model validation on fields that are not part of the form. Thanks, Honza Kral and Ivan Sagalaev.

This reverts some admin and test changes from [12098] and also fixes #12507, #12520, #12552 and #12553.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12206 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Joseph Kocherhans
2010-01-12 02:29:45 +00:00
parent 26279c5721
commit 2f9853b2dc
17 changed files with 427 additions and 135 deletions

View File

@@ -33,7 +33,7 @@ class FieldError(Exception):
pass
NON_FIELD_ERRORS = '__all__'
class BaseValidationError(Exception):
class ValidationError(Exception):
"""An error while validating data."""
def __init__(self, message, code=None, params=None):
import operator
@@ -64,10 +64,14 @@ class BaseValidationError(Exception):
return repr(self.message_dict)
return repr(self.messages)
class ValidationError(BaseValidationError):
pass
class UnresolvableValidationError(BaseValidationError):
"""Validation error that cannot be resolved by the user."""
pass
def update_error_dict(self, error_dict):
if hasattr(self, 'message_dict'):
if error_dict:
for k, v in self.message_dict.items():
error_dict.setdefault(k, []).extend(v)
else:
error_dict = self.message_dict
else:
error_dict[NON_FIELD_ERRORS] = self.messages
return error_dict