I want to render all datetime objects in all templates in a django application in a certain manner, using common code for all datetime objects that might be passed all the way to the template.
Without going too much in to details, please note that the following are not viable otions.:
- use a filter or a custom template tag in the template
- subclassing datetime
- setting
DATETIME_FORMATto a magic value - using a custom timezone and some TimeZoneMiddlWare
Create your own datetime class and monkeypatch the datetime module early in the app setup.
(Maybe you need to monkeypatch all imported modules too, depends on how early you can do this
It’s easier if you subclass the datetime object for sure, but you don’t have to.