I have a DateTimeField in my model.
When I add this field to admin.py , then the format shows as 4:00 pm , how can this be changed to 16:00?
creation_date = models.DateTimeField(auto_now_add=True,)
If I do this
def time(self):
return self.creation_date.timezone().strftime('%Y-%m-%d %H:%M:%S')
that time field is not sorted
You can override the format with the
DATETIME_FORMAT
setting: https://docs.djangoproject.com/en/4.2/ref/settings/#datetime-format