2

我正在尝试从 MySQL 迁移到 PostgreSQL,现在我遇到了具体基类的问题。我有类似这样的代码:

class BaseKlass(models.Model):
    name = CharField(max_length = 64)

class SomeKlass(BaseKlass):
    value = IntegerField()

每当我创建 的实例时SomeKlass,都会收到如下错误:

IntegrityError: null value in column "baseklass_ptr_id" violates not-null constraint

baseklass_ptr_id我查看了正在执行的 SQL,确实值为null.

任何的想法?

4

1 回答 1

2

为序列设置所有者id解决了这个问题:

ALTER SEQUENCE myapp_baseklass_id_seq OWNED BY myapp_baseklass.id;
于 2012-12-29T18:25:49.053 回答