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

2个回答

原因为缺少依赖包导致,安全如下依赖包即可:

yum install sqlite-devel

dabaine
dabaine windows下需要引入什么包吗
10 个月之前 回复

首先重新建个项目看是否好使,重新写一个简单的模型类(一定是好使的)。
那么可以认为你现在的模型类设计有问题,其中的一些字段没有满足Field条件,先把认为问题的字段给屏蔽掉重新运行一次,查看结果。
你这个和我的报错结果是一样的,应该是时间字段设置有问题,可以查看一下。
PS:CSDN管理员这么Sb吗,追问一下都给删了,现在还要继续删吗?????????

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐