diff options
| author | Tim Graham <timograham@gmail.com> | 2018-08-07 18:04:48 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-08-08 06:38:27 -0400 |
| commit | e3be4e94d1bc38f9aac087a40eebd0a46c3dacea (patch) | |
| tree | 97765f85421a3e6e5797cef4e94d57f86ccfb5fe /django | |
| parent | 2bf766cedca413826d599ac190fd6715429616f6 (diff) | |
[2.1.x] Fixed #29623 -- Fixed translation failure of DurationField's "overflow" error message.
Backport of 730173d1c5cf210d8e3bd951fa49f64b9bc561ca from master
Diffstat (limited to 'django')
| -rw-r--r-- | django/forms/fields.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py index 370f78e8b5..6e19c79144 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -468,12 +468,7 @@ class DateTimeField(BaseTemporalField): class DurationField(Field): default_error_messages = { 'invalid': _('Enter a valid duration.'), - 'overflow': _( - 'The number of days must be between {min_days} and {max_days}.'.format( - min_days=datetime.timedelta.min.days, - max_days=datetime.timedelta.max.days, - ) - ) + 'overflow': _('The number of days must be between {min_days} and {max_days}.') } def prepare_value(self, value): @@ -489,7 +484,10 @@ class DurationField(Field): try: value = parse_duration(str(value)) except OverflowError: - raise ValidationError(self.error_messages['overflow'], code='overflow') + raise ValidationError(self.error_messages['overflow'].format( + min_days=datetime.timedelta.min.days, + max_days=datetime.timedelta.max.days, + ), code='overflow') if value is None: raise ValidationError(self.error_messages['invalid'], code='invalid') return value |
