I have a model that shows a short string in __str__()
method of the model
def __str__(self):
return \"Scheduled at %s\" % (self.date_time.strfti
Django converts datetimes when displaying values with templates. If you want to do the conversion in arbitrary blocks of code, use the localtime() helper:
from django.utils.timezone import localtime
def __str__(self):
return "Scheduled at %s" % localtime(self.date_time).strftime("%B %d %Y %I:%M %p")