我有一个采用修改后的时间戳的表格,但是这些时间戳永远不会在将来出现。我创建了下面的函数,以便将来有人尝试提交时间时引发错误,但是,我不断收到此错误
TypeError at /operations/enter-exit-area/
can't compare offset-naive and offset-aware datetimes
Request Method: POST
Request URL: http://localhost:8000/operations/enter-exit-area/
Django Version: 2.1.5
Exception Type: TypeError
Exception Value: can't compare offset-naive and offset-aware datetimes
Exception Location: C:\Users\mkusneco\apps.rsrgroup.com\apps\operations\forms.py in clean_modified_in,line 48
def clean_modified_in(self):
mod_in = self.cleaned_data.get('modified_in')
if mod_in > datetime.datetime.now():
raise forms.ValidationError("The modified time cannot be in the future")
return mod_in