我在一个新的网站上使用了south和django,并附有一个postgres数据库。我正在尝试初始迁移,但得到以下错误django.db.utils.DatabaseError:无效的输入语法为整数:当这一行被调用('views',self.gf('django.db.models。 fields.IntegerField')(default = 0)),
I am using south and django on a new site with a postgres database. I am attempting to do the initial migration but get the following error django.db.utils.DatabaseError: invalid input syntax for integer: "" when this line is called ('views', self.gf('django.db.models.fields.IntegerField')(default=0)),
在模型中转换为这个视图= models.IntegerField(default = 0)
which translates to this in the model views = models.IntegerField(default=0)
这一切都适用于本地的sqllite,任何人都知道为什么会发生这种情况?
This all works fine with sqllite locally, anyone know why this is happening?
感谢,CG
推荐答案正如您在评论中提到的那样,将默认设置为1来修正问题。我知道你会想知道为什么。
As you mentioned in your comments, setting the default to 1 fixed the problem. I understand you'd like some idea of why.
sqlite将大多数数据存储为字符串,所以是一个完全有效的值。 PostgreSQL提供严格的检查,所以你不能发送''但NULL是可以接受的。
sqlite stores most data as strings, so '' is a perfectly valid value there. PostgreSQL provides strict checking so you can't send '' but NULL is acceptable.
更多推荐
Django,南,postgres初始迁移错误
发布评论