例如,我在同一个数据库中有两个模型
# one managed by other app
class Package(models.Model):
id = models.TextField(primary_key=True)
title = models.TextField(blank=True, null=True)
# ....
class Meta:
managed = False # !
db_table = 'package'
# and one managed by django
class CustomPackage(models.Model):
package = models.OneToOneField(Package, related_name='+', null=True, default=None)
featured = models.BooleanField(default=False)
# more fields ...
但是一旦我使用CustomPackage或Package实例,我就会收到错误:
ProgrammingError at /
relation "ckanwrap_custompackage" does not exist
LINE 1: ..."featured", "myapp__custompackage"."photo" FROM "myapp_...
同样在django admin中。当我有一些播放数据时没关系,但是当我转到postgresql时 - 出现这个错误。
如果其中一个模型在Meta中有manage=Flase
,那么Django ORM不会创建关系表吗?