为什么我在datetime字段中的clean()抛出TypeError?

我有一个采用修改后的时间戳的表格,但是这些时间戳永远不会在将来出现。我创建了下面的函数,以便将来有人尝试提交时间时引发错误,但是,我不断收到此错误

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
climb166 回答:为什么我在datetime字段中的clean()抛出TypeError?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2905107.html

大家都在问