如何比较Django中的日期

例子1:
from datetime import date

@property
def is_past_due(self):
    return date.today() > self.date
{% if listing.is_past_due %}
    In the past
{% else %}
    {{ listing.date|date:"d M Y" }}
{% endif %}

例子2:判断日期小于一年,前端显示不同的颜色

 

猜你喜欢

转载自blog.csdn.net/qq_42336556/article/details/84285552