[Answered ]-Django: Format dates according to settings.LANGUAGE_CODE in code (e.g. messages)

1👍

format_date would be great here, it get a string representation of a date according to the current locale

first we import it from django.utils import formats then change your code like that

self.success_message = (
    f"Eingeschrieben für <b>{formats.date_format(self.date, 'l')}</b>, "
    f"den {formats.date_format(self.date, 'j. F Y')}.".replace(" 0", " ")
)

Leave a comment