【发布时间】:2013-12-08 17:36:16
【问题描述】:
我有以下型号:
class CulturalDocument(CacheMixin, models.Model):
...
uuid = UUIDField(unique=True)
class Genre(CulturalDocument):
name = models.CharField(max_length=32)
...
class Album(CulturalDocument):
...
genre = models.ForeignKey(Genre, null=True, blank=True)
我添加了带有南迁移的genre 属性。
我可以使用 pg_admin 在表 music_album 中看到 genre_id 列。
但是,当我这样做时:
album = Album.objects.create(uuid=3,
release_date=datetime(2000, 1, 1),
title="Fantastic Album",
right_holder=rh)
我明白了:
"ProgrammingError: column "genre_id" of relation "music_album" does not exist" while the column does exist
LINE 1: ..._id", "title", "release_date", "right_holder_id", "genre_id"...
. ^
在 Ubuntu 12.04 中使用 PostGres 9.2 和 Django 1.6。
生成的SQL是:
INSERT INTO "music_album" ("culturaldocument_ptr_id", "title", "release_date", "right_holder_id", "genre_id") VALUES (%s, %s, %s, %s, %s)
【问题讨论】:
-
真的存在吗?
select * from information_schema.columns where table_name = 'music_album'的输出是什么 -
返回(0 行)。但是“music_album”确实存在,因为我在其中存储数据并从中检索数据。
标签: python django postgresql orm