问题
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