当我尝试从管理界面向我的应用程序的“设备”表添加内容时,我正在制作Django应用程序并遇到以下问题: 列device.plID_id不存在
这是课程:
class Device(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(max_length = 20)
slug = models.SlugField(unique=True,help_text='URL page created from name')
model_name = models.CharField(max_length = 20)
plID = models.ForeignKey('onep_web.Platform', unique = False)
sdkID = models.ForeignKey('onep_web.SDKVersion',unique = False)
IPID = models.ForeignKey('onep_web.IPAddress',unique = False)
和sqall命令的输出:
BEGIN;
CREATE TABLE "device" (
"id" integer NOT NULL PRIMARY KEY,
"name" varchar(20) NOT NULL,
"slug" varchar(50) NOT NULL UNIQUE,
"model_name" varchar(20) NOT NULL,
"plID_id" integer NOT NULL,
"sdkID_id" integer NOT NULL,
"IPID_id" integer NOT NULL
)
;
CREATE TABLE "platform" (
"id" integer NOT NULL PRIMARY KEY,
"platform_name" varchar(20) NOT NULL
)
;
ALTER TABLE "device" ADD CONSTRAINT "plID_id_refs_id_364a8522" FOREIGN KEY ("plID_id") REFERENCES "platform" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE TABLE "sdk_ver" (
"id" integer NOT NULL PRIMARY KEY,
"language" varchar(20) NOT NULL,
"version" numeric(100, 100) NOT NULL
)
;
ALTER TABLE "device" ADD CONSTRAINT "sdkID_id_refs_id_bb71f431" FOREIGN KEY ("sdkID_id") REFERENCES "sdk_ver" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE TABLE "ip_addr" (
"id" integer NOT NULL PRIMARY KEY,
"ip" inet NOT NULL
)
;
ALTER TABLE "device" ADD CONSTRAINT "IPID_id_refs_id_7c42b845" FOREIGN KEY ("IPID_id") REFERENCES "ip_addr" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE TABLE "files" (
"id" integer NOT NULL PRIMARY KEY,
"file" varchar(100) NOT NULL,
"isConfig" boolean NOT NULL
)
;
CREATE INDEX "device_slug_like" ON "device" ("slug" varchar_pattern_ops);
CREATE INDEX "device_plID_id" ON "device" ("plID_id");
CREATE INDEX "device_sdkID_id" ON "device" ("sdkID_id");
CREATE INDEX "device_IPID_id" ON "device" ("IPID_id");
当只有两个表时Device和Platform一切正常。在我添加了几个表后,我遇到了这个问题
答案 0 :(得分:0)
Django的manage.py,不使用或处理迁移(当前)你需要使用south来改变表(当你改变模型时): http://south.aeracode.org/
向南安装,按照详细说明操作,您可以轻松地更新您的架构。