解决Django出现OverflowError: Python int too large to convert to C long

  File "C:\Users\huaixiao\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "C:\Users\huaixiao\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\backends\sqlite3\base.py", line 383, in execute
    return Database.Cursor.execute(self, query, params)
  File "C:\Users\huaixiao\AppData\Local\Programs\Python\Python37-32\lib\sqlite3\dbapi2.py", line 64, in convert_date
    return datetime.date(*map(int, val.split(b"-")))
OverflowError: Python int too large to convert to C long
[16/Jul/2020 13:48:42] "GET /todo/index/ HTTP/1.1" 500 181731

查看报错中存在此句,return datetime.date(*map(int, val.split(b"-")))

查看源代码中确实有DataField:
finish_time=models.DateField()
解决Django出现OverflowError: Python int too large to convert to C long_第1张图片
DataField转到数据库的是精确时间,即 年-月-日 时-分-秒。因为 DateField是日期项,没法精确到时分秒。所以这里出现溢出错误。将 DateField改为 DateTimeField,重新初始化数据库以后问题就消失了,能够正常访问。

你可能感兴趣的:(django,python)