python3.7,django 2.21,for...in...Python int too large to convert to C long

def index(request):
obj = datas.objects.all() # 数据只有两条
for foo in obj:
print(foo)
return render(request, 'index.html', {'obj': obj})
报以下错误:求帮助

Internal Server Error: /
Traceback (most recent call last):
File "E:\PythonProjects\SMMS\venv\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "E:\PythonProjects\SMMS\venv\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "E:\PythonProjects\SMMS\venv\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "E:\PythonProjects\SMMS\db\views.py", line 12, in index
for foo in obj:
File "E:\PythonProjects\SMMS\venv\lib\site-packages\django\db\models\query.py", line 274, in __iter__
self._fetch_all()
File "E:\PythonProjects\SMMS\venv\lib\site-packages\django\db\models\query.py", line 1242, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "E:\PythonProjects\SMMS\venv\lib\site-packages\django\db\models\query.py", line 55, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "E:\PythonProjects\SMMS\venv\lib\site-packages\django\db\models\sql\compiler.py", line 1100, in execute_sql
cursor.execute(sql, params)
File "E:\PythonProjects\SMMS\venv\lib\site-packages\django\db\backends\utils.py", line 99, in execute
return super().execute(sql, params)
File "E:\PythonProjects\SMMS\venv\lib\site-packages\django\db\backends\utils.py", line 67, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "E:\PythonProjects\SMMS\venv\lib\site-packages\django\db\backends\utils.py", line 76, in _execute_with_wrappers
return executor(sql, params, many, context)
File "E:\PythonProjects\SMMS\venv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "E:\PythonProjects\SMMS\venv\lib\site-packages\django\db\backends\sqlite3\base.py", line 383, in execute
return Database.Cursor.execute(self, query, params)
File "D:\Program Files\Python37\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

你的代码,是否还调用了C写的某个函数?这个错误是python中的int值范围超过了C中的int值范围,如果你能找到这个int值,转换为long类型,应该就可以了
温馨提示:答案为网友推荐,仅供参考