我只是想在模型上添加一个字段。
class Categories(models.Model):
#this IDUnique = models.IntegerField(max_length=11, blank=True, null=True)
IDParent = models.IntegerField(max_length=11, blank=True, null=True)
Name = models.CharField(max_length=45, blank=False)
当我尝试迁移时:
Operations to perform:
Synchronize unmigrated apps: formtools, social_auth, crispy_forms, django_comments
Apply all migrations: sessions, admin, sites, auth, appname, contenttypes
Synchronizing apps without migrations:
Creating tables...
Installing custom SQL...
Installing indexes...
Running migrations:
No migrations to apply.
删除并再次迁移并尝试 sqlmigrate
BEGIN;
CREATE TABLE "appname_category__new" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "IDParent" integer NULL, "Name" varchar(45) NOT NULL, "IDUnique" integer NULL);
INSERT INTO "appname_category__new" ("Name", "id", "IDParent") SELECT "Name", "id", "IDParent" FROM "appname_category";
DROP TABLE "appname_category";
ALTER TABLE "appname_category__new" RENAME TO "appname_category";
COMMIT;
仍然说
no such column: onlinemarket_categories.IDUnique
谢谢