i get an "Out of range value adjusted for column"
我得到“超出范围值调整列”
not sure whether there is a fix for this in django
不确定django中是否有修复方法
4 个解决方案
#1
You should create custom field inhrited from Field or IntegerField
您应该创建从Field或IntegerField中注入的自定义字段
class BigintField(models.Field):
def db_type(self):
return 'BIGINT(20)'
...
and
class MyModel(models.Model):
bigid = BigintField()
#2
For modern Django versions, use the models.BigIntegerField
. It supports larger values.
对于现代Django版本,请使用models.BigIntegerField。它支持更大的值。
#3
Django ticket #399 deals with this. I also opened a similar question quite some time ago.
Django门票#399处理此事。不久前我也提出了类似的问题。
A workaround that I have used in the past is to simply ALTER
the field in question directly in the DB table to BIGINT
(for MySQL, for example). Note, however, that if you reset the application in which the particular model with the particular field exists, or drop the table and recreate it by any means, you will have to ALTER
the field again.
我过去使用的一种解决方法是简单地将DB表中的字段直接更改为BIGINT(例如,用于MySQL)。但请注意,如果重置具有特定字段的特定模型的应用程序,或者删除表并以任何方式重新创建它,则必须再次更改该字段。
#4
For South users, django's built-in DecimalField may work better than the custom BigintField approach above. Looks like it takes a bit of extra work to teach South about custom field types.
对于南方用户,django的内置DecimalField可能比上面的自定义BigintField方法更好。看起来需要一些额外的工作来教南方关于自定义字段类型。
#1
You should create custom field inhrited from Field or IntegerField
您应该创建从Field或IntegerField中注入的自定义字段
class BigintField(models.Field):
def db_type(self):
return 'BIGINT(20)'
...
and
class MyModel(models.Model):
bigid = BigintField()
#2
For modern Django versions, use the models.BigIntegerField
. It supports larger values.
对于现代Django版本,请使用models.BigIntegerField。它支持更大的值。
#3
Django ticket #399 deals with this. I also opened a similar question quite some time ago.
Django门票#399处理此事。不久前我也提出了类似的问题。
A workaround that I have used in the past is to simply ALTER
the field in question directly in the DB table to BIGINT
(for MySQL, for example). Note, however, that if you reset the application in which the particular model with the particular field exists, or drop the table and recreate it by any means, you will have to ALTER
the field again.
我过去使用的一种解决方法是简单地将DB表中的字段直接更改为BIGINT(例如,用于MySQL)。但请注意,如果重置具有特定字段的特定模型的应用程序,或者删除表并以任何方式重新创建它,则必须再次更改该字段。
#4
For South users, django's built-in DecimalField may work better than the custom BigintField approach above. Looks like it takes a bit of extra work to teach South about custom field types.
对于南方用户,django的内置DecimalField可能比上面的自定义BigintField方法更好。看起来需要一些额外的工作来教南方关于自定义字段类型。