我有两个模型:
class City(models.Model):
name = models.CharField(max_length=50)
country = models.OneToOneField(Country)
def __unicode__(self):
return self.name
class UserProfile(models.Model):
user = models.OneToOneField(User)
city = models.OneToOneField(City)
当我同步数据库并创建管理员用户时:
IntegrityError: null value in column "city_id" violates not-null constraint
如何修复此错误?