答案就在这里——我希望这能帮助别人!在
这是我的模型.py代码:class VlogDetails(models.Model):
....
vlog_date_published = models.DateField(null=False, blank=False, default=datetime.now, help_text='The date the vlog video will be made public.')
....
# date published replaces vlog_date_published in the admin - displays red date when vlog not published.
def date_published(self):
if self.vlog_date_published > datetime.today().date():
return format_html('{0}', self.vlog_date_published.strftime('%b. %d, %Y'))
else:
return format_html('{0}', self.vlog_date_published.strftime('%b. %d, %Y'))
date_published.allow_tags = True
class Meta:
....
这是我的管理员py代码:
^{pr2}$
这是视觉表现: