验证时间超期日期超过特定日期4个月

 1 def clean_bdsx(self):
 2         year=self.cleaned_data['tysj'].year #'tysj'为特定日期
 3         month=self.cleaned_data['tysj'].month
 4         year_add,month_max= divmod((month+3),12)
 5         limit_date=datetime.date(year+year_add,month_max+1,1)
 6         # print('eeeeeeeeeeeeeeeeeee',limit_date)
 7         if self.cleaned_data['bdsx']>=limit_date:#需验证的日期
 8             raise ValidationError("超过特定时间4个月")
 9         else:
10             return self.cleaned_data['bdsx']

 

posted on 2023-03-05 07:42  ldx-wsj  阅读(15)  评论(0)    收藏  举报