例子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:判断日期小于一年,前端显示不同的颜色
例子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:判断日期小于一年,前端显示不同的颜色