简单介绍:做删除的时候,需要判断XX的日期,如果在有效期内,则不能删除,已过期,或者是未生效都可以删除.刚看到的时候,就有点懵逼了,因为不知道该怎么判断,最初,想的是查询XX的开始日期和截止日期,看看当前时间 new Date() 是否在between startTime and endTime 之外,如果是的话,就可以删除,否则,不能删除,想法倒是挺美的,关键是怎么写sql啊,难道sql还能返回true false?结果就卡在这里了.后来,我灵机一动,终于想出来了该怎么做,hah༺༺超༒…
from rest_framework.authentication import BaseAuthentication from rest_framework.exceptions import AuthenticationFailed from api.models import Token import datetime from django.core.cache import cache import pytz class LoginAuth(BaseAuthentication):…