G
G
gaalev2020-06-03 12:32:46
Django
gaalev, 2020-06-03 12:32:46

How to localize date in Django?

settings.py

LANGUAGE_CODE = 'ru-RU'

TIME_ZONE = 'Europe/Moscow'

USE_I18N = True

USE_L10N = True

USE_TZ = True

DATE_FORMAT = 'j F Y'
TIME_FORMAT = 'H:i'
DATETIME_FORMAT = 'j F Y, H:i'

in the template {{article.pub_date|date:"DATETIME_FORMAT"}}
The output is June 3, 2020 12:05 pm. If you change DATE_FORMAT, TIME_FORMAT or DATETIME_FORMAT nothing will change. How to remove "g." and make your own date format?
If the date formats are commented out and written in the template, then everything will be as it should:
article.pub_date|date:"j F Y, H:i"
Only now it doesn’t look in Russian: June 3, 2020, 12:05 pm

Newbies today are like uncut dogs. And they themselves can not understand anything ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Alyukov, 2020-06-03
@gaalev

Play around with this - Built-in template tags and filters # date

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question