python - 整数超出范围

标签 python django

尝试将我的数据库从 SQLite 迁移到 PostgreSQL 时,我遇到了一个整数超出范围错误。

我想我已经指出了问题所在:我的模型中的 IntegerField 字段中有一些巨大的整数。

基本按照52675215334的顺序

当我将此值更改为较小的数字(例如 1)然后尝试迁移我的数据库时,一切正常。

除了 IntegerField 之外,我应该使用其他数据类型来存储这些大值吗?

最佳答案

尝试使用 BigIntegerField如果你的整数那么大。来自文档:

A 64 bit integer, much like an IntegerField except that it is guaranteed to fit numbers from -9223372036854775808 to 9223372036854775807. The admin represents this as an <input type="text"> (a single-line input).

关于python - 整数超出范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11302711/

相关文章:

Python + readline + 自动完成(tab): why are dashes and question-marks treated as word-separators?

Python:转换以字节数组形式编码十六进制的 json 字符串

python - 我无法扩展模板 django

python - 如何在 django 中使用 handler404 View ?

python - Django 上的用户角色架构

python - Numpy "double"-广播 - 有可能吗?

python - Gedit 无法获取有关窗口创建的 View (插件开发)

python - Django 表单在模型表单上无效

python - 在 Django 应用程序中实现 memcached 需要哪些步骤?

python - Django - 无法获取对象列表中对象的特定主键(id)