Closed max-block closed 2 years ago
I have run into this too. Switching a template from django to jinja will always break date formatting.
Django's template engine implicitly renders {{ value }}
as {{ value|date }}
, if the value is a date or datetime. From what I can tell, jinja simply runs {{ str(value) }}
, which is not as pretty as the django date filter.
django-jinja does the work of hooking up django's date filter, so switching your templates to {{ value|date }}
should get it to render according like how django does it, and this is what I do in my project. Edit: I do also see {{ value|date('DATETIME_FORMAT') }}
being used to explicitly refer to the settings format string in a few cases.
I do not know of a way to instruct jinja to use a default filter for a certain type, like django implicitly does for date types, if that is what you mean.
marking this as closed as I've addressed the question. however, i would support a PR that emulates the django behavior.
Are there any solutions how to have a default datetime formatter with jinja?