1
0
mirror of https://github.com/django/django.git synced 2025-10-25 22:56:12 +00:00

Fixed #20199 -- Allow ModelForm fields to override error_messages from model fields

This commit is contained in:
Loic Bistuer
2013-06-05 14:55:05 -04:00
committed by Tim Graham
parent f34cfec0fa
commit ee77d4b253
22 changed files with 403 additions and 149 deletions

View File

@@ -85,7 +85,10 @@ class BaseFormSet(object):
if self.is_bound:
form = ManagementForm(self.data, auto_id=self.auto_id, prefix=self.prefix)
if not form.is_valid():
raise ValidationError('ManagementForm data is missing or has been tampered with')
raise ValidationError(
_('ManagementForm data is missing or has been tampered with'),
code='missing_management_form',
)
else:
form = ManagementForm(auto_id=self.auto_id, prefix=self.prefix, initial={
TOTAL_FORM_COUNT: self.total_form_count(),
@@ -315,7 +318,9 @@ class BaseFormSet(object):
self.management_form.cleaned_data[TOTAL_FORM_COUNT] > self.absolute_max:
raise ValidationError(ungettext(
"Please submit %d or fewer forms.",
"Please submit %d or fewer forms.", self.max_num) % self.max_num)
"Please submit %d or fewer forms.", self.max_num) % self.max_num,
code='too_many_forms',
)
# Give self.clean() a chance to do cross-form validation.
self.clean()
except ValidationError as e: