Python Django抽象模型南移错误
我有以下型号:Python Django抽象模型南移错误,python,django,django-models,django-south,Python,Django,Django Models,Django South,我有以下型号: class MemberCategory(BaseModel): """ Contains Predfined Category Types """ title = models.CharField(null=True, blank=True, max_length=100) description = models.TextField(null=True, blank=True) slug = models.SlugField(
class MemberCategory(BaseModel):
"""
Contains Predfined Category Types
"""
title = models.CharField(null=True, blank=True, max_length=100)
description = models.TextField(null=True, blank=True)
slug = models.SlugField(null=True, blank=True)
基本模型如下所示:
class BaseModel(models.Model):
"""
An abstract base class model that provides self-managed "created" and
"modified" multi tenant fields.
"""
creation_date = models.DateTimeField(auto_now_add=True)
modification_date = models.DateTimeField(auto_now=True)
class Meta:
abstract = True
class MemberCategory(BaseModel):
"""
Contains Predfined Category Types
"""
title = models.CharField(null=True, blank=True, max_length=100)
description = models.TextField(null=True, blank=True)
slug = models.SlugField(null=True, blank=True)
orgs = models.ForeignKey(Org, null=True, blank=True)
现在,我在我的MemberCategory中添加一个字段org
,这样新模型如下所示:
class BaseModel(models.Model):
"""
An abstract base class model that provides self-managed "created" and
"modified" multi tenant fields.
"""
creation_date = models.DateTimeField(auto_now_add=True)
modification_date = models.DateTimeField(auto_now=True)
class Meta:
abstract = True
class MemberCategory(BaseModel):
"""
Contains Predfined Category Types
"""
title = models.CharField(null=True, blank=True, max_length=100)
description = models.TextField(null=True, blank=True)
slug = models.SlugField(null=True, blank=True)
orgs = models.ForeignKey(Org, null=True, blank=True)
在此之后,我执行-python manage.py模式迁移--auto
无错误,一切正常
然后我执行python manage.py migrate
,这会引发以下错误-
KeyError: u'creation_date'
有什么原因导致我出现这个错误吗?只是为了确定一下。您第一次使用python manage.py模式迁移了吗?只有当数据库中已经存在表时,--auto选项才起作用。是否有可能在粘贴箱中删除最后两次迁移?