diff --git a/django/forms/formsets.py b/django/forms/formsets.py
index a89c35599f..39cd47866a 100644
a
|
b
|
from django.forms.widgets import HiddenInput, NumberInput
|
6 | 6 | from django.utils.functional import cached_property |
7 | 7 | from django.utils.html import html_safe |
8 | 8 | from django.utils.safestring import mark_safe |
9 | | from django.utils.translation import gettext_lazy as _, ngettext |
| 9 | from django.utils.translation import gettext_lazy as _, ngettext_lazy |
10 | 10 | |
11 | 11 | __all__ = ('BaseFormSet', 'formset_factory', 'all_valid') |
12 | 12 | |
… |
… |
class BaseFormSet:
|
61 | 61 | 'ManagementForm data is missing or has been tampered with. Missing fields: ' |
62 | 62 | '%(field_names)s. You may need to file a bug report if the issue persists.' |
63 | 63 | ), |
| 64 | 'too_many_forms': ngettext_lazy( |
| 65 | "Please submit at most {num} form.", |
| 66 | "Please submit at most {num} forms.", |
| 67 | 'num' |
| 68 | ), |
| 69 | 'too_few_forms': ngettext_lazy( |
| 70 | "Please submit at least {num} form.", |
| 71 | "Please submit at least {num} forms.", |
| 72 | 'num' |
| 73 | ), |
64 | 74 | } |
65 | 75 | |
66 | 76 | def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, |
… |
… |
class BaseFormSet:
|
366 | 376 | if (self.validate_max and |
367 | 377 | self.total_form_count() - len(self.deleted_forms) > self.max_num) or \ |
368 | 378 | self.management_form.cleaned_data[TOTAL_FORM_COUNT] > self.absolute_max: |
369 | | raise ValidationError(ngettext( |
370 | | "Please submit at most %d form.", |
371 | | "Please submit at most %d forms.", self.max_num) % self.max_num, |
| 379 | raise ValidationError( |
| 380 | self.error_messages['too_many_forms'].format(num=self.max_num), |
372 | 381 | code='too_many_forms', |
373 | 382 | ) |
374 | 383 | if (self.validate_min and |
375 | 384 | self.total_form_count() - len(self.deleted_forms) - empty_forms_count < self.min_num): |
376 | | raise ValidationError(ngettext( |
377 | | "Please submit at least %d form.", |
378 | | "Please submit at least %d forms.", self.min_num) % self.min_num, |
379 | | code='too_few_forms') |
| 385 | raise ValidationError( |
| 386 | self.error_messages['too_few_forms'].format(num=self.min_num), |
| 387 | code='too_few_forms', |
| 388 | ) |
380 | 389 | # Give self.clean() a chance to do cross-form validation. |
381 | 390 | self.clean() |
382 | 391 | except ValidationError as e: |