我收到一个 DatabaseError,说不存在名为 playlist 的列,我正在尝试找出解决方法。我用的是南方。我删除了迁移文件夹中的旧文件并运行:
python manage.py schemamigration app_name --initial
python manage.py migrate reserve
执行此操作时出现此错误:
south.exceptions.GhostMigrations:
! These migrations are in the database but not on disk:
<reserve: 0002_initial>
! I'm not trusting myself; either fix this yourself by fiddling
! with the south_migrationhistory table, or pass --delete-ghost-migrations
! to South to have it delete ALL of these records (this may not be good).
我不知道如何摆脱这个错误,因为在我的迁移文件夹中我只有 init.py(c) 和 0001_initial.py(c); 我没有 0002 迁移文件了。
当我尝试运行服务器并在管理员中单击“添加播放列表”时,这是我收到 DatabaseError 的时候。如果有帮助,我的 models.py 是:
class UserProfile(models.Model):
user = models.OneToOneField(User)
def __unicode__(self):
return self.user
def create_user_profile(sender, instance, created, **kwargs):
if created:
UserProfile.objects.create(user=instance)
post_save.connect(create_user_profile, sender=User)
class Playlist(models.Model):
playlist = models.CharField('Playlist', max_length = 2000, null=True, blank=True)
def __unicode__(self):
return self.playlist
class Video(models.Model):
video_url = models.URLField('Link to video', max_length = 200, null=True, blank=True)
def __unicode__(self):
return self.video_url
class UserPlaylist(models.Model):
profile = models.ForeignKey(User)
playlist = models.ForeignKey(Playlist)
def __unicode__(self):
return self.playlist
class Videoplaylist(models.Model):
video = models.ForeignKey(Video)
playlist = models.ForeignKey(UserPlaylist)
def __unicode__(self):
return self.playlist
关于如何解决这个问题的任何建议?