How to make Django Models store `DateTimeField` without microseconds?
I would like store a date in the format M-D, H:M. Is there a way to achieve that with Django Models without using templating and filters or datetime?
Code:
date = models.DateTimeField(auto_now=True)
Output:
2026-03-07 21:52:34.765959
Wanted output:
03-07, 21:52
DateTimeField stores datetime objects, so the most viable solution would be to format it when passing the data to wherever you're trying to show it.
date = post.date.strftime('%m-%d, %H:%M')