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

Fixed #29623 -- Fixed translation failure of DurationField's "overflow" error message.

This commit is contained in:
Tim Graham
2018-08-07 18:04:48 -04:00
parent 9fee229874
commit 730173d1c5
3 changed files with 18 additions and 7 deletions

View File

@@ -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