We have several locales and we want to add a MinValueValidator for a date. We noticed that the error message is in the correct language, but the date format is not.
Example model:
Class Report(models.Model):
start = models.DateField(
verbose_name=_("Start Date"),
blank=True,
null=True,
default=None,
validators=[MinValueValidator(date(2020, 1, 1))],
)
Example outout:
Dieser Wert muss größer oder gleich 2020-01-01 sein.
The expected date format for the German locale would be: 01.01.2020
.
When checking the BaseValidator class, one can see that it simply passes the limit_value but does not localize it.
So the question is:
a) am I doing something wrong here?
b) could this be a feature request for django itself?
I’m aware, that I can override the validator class and localize it or pass a custom message.
But I think it could improve the localization of django websites if it a) automatically localize the value when outputting the message or b) there could be a localize
parameter (similar to the form field localize
parameter