Django,南,postgres初始迁移错误 [英] Django, south, postgres initial migration error

查看:150
本文介绍了Django,南,postgres初始迁移错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个新的网站上使用了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初始迁移错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆