Django, south, postgres initial migration error

痞子三分冷 提交于 2019-12-24 00:06:10

问题


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)),

which translates to this in the model

views = models.IntegerField(default=0)

This all works fine with sqllite locally, anyone know why this is happening?


回答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 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.



来源:https://stackoverflow.com/questions/7451465/django-south-postgres-initial-migration-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!