我有以下型号 -
class ToDo(models.Model):
todo_title = models.CharField(null=True, blank=True, max_length=200)
todo_status = models.IntegerField(choices=TASK_STATUS, null=True, blank=True)
assigned_to = models.ManyToManyField(OrgStaff, null=True, blank=True, related_name='assigned_to')
assigned_by = models.ManyToManyField(OrgStaff, null=True, blank=True, related_name='assigned_by')
assigned_time = models.DateTimeField(auto_now_add=True)
completed_time = models.DateTimeField(null=True, blank=True)
然后我运行python manage.py convert_to_south todoapp
todoapp是应用程序的名称。然后我跑python manage.py migrate todoapp.
完成后,我在上述模型中添加另一个字段 -
class ToDo(models.Model):
todo_title = models.CharField(null=True, blank=True, max_length=200)
todo_slug = models.SlugField(null=True, blank=True)
todo_status = models.IntegerField(choices=TASK_STATUS, null=True, blank=True)
assigned_to = models.ManyToManyField(OrgStaff, null=True, blank=True, related_name='assigned_to')
assigned_by = models.ManyToManyField(OrgStaff, null=True, blank=True, related_name='assigned_by')
assigned_time = models.DateTimeField(auto_now_add=True)
completed_time = models.DateTimeField(null=True, blank=True)
现在我进行模式迁移-python manage.py schemamigration todoapp --auto
然后python manage.py migrate todoapp
这样做会出现以下错误-
Running migrations for taskbase:
- Migrating forwards to 0002_auto__add_field_todo_todo_slug.
> taskbase:0002_auto__add_field_todo_todo_slug
KeyError: u'todo_title'
知道为什么我会收到此错误吗? 我敲了敲头,却找不到原因。