擅长:python、mysql、java
<p>所以,输入日期不能在过去,也不能在<code>23:59</code>之后,所以基本上它需要在今天的剩余时间内。你知道吗</p>
<p>怎么样:</p>
<pre class="lang-py prettyprint-override"><code>import pytz
def date_is_not_past(dt):
if dt < datetime.now(pytz.UTC):
raise ValidationError('Date cannot be in the past')
def date_is_today(dt):
if dt.date() != datetime.now(pytz.UTC).date():
raise ValidationError('Date needs to be today')
</code></pre>