删除我的数据库后,我仍然得到"编程错误:列post_post.hash不存在"

时间:2018-03-24 22:48:16

标签: python django

这怎么可能?我做了python manage.py flush删除了数据库。我也卸载并重新安装了django。然后我做了makemigrationsmigrate。但我在log.django文件中收到此错误:

  File "/home/zorgan/app/env/lib/python3.5/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/zorgan/app/env/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/zorgan/app/env/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column post_post.hash does not exist
LINE 1: SELECT "post_post"."id", "post_post"."hash", "post_post"."us...

这是指我的模特:

class Post(models.Model):
    hash = models.CharField(max_length=18, default=random_string, null=True, blank=True)


class PostScore(models.Model):
    user = models.ForeignKey(User, blank=True, null=True)
    post = models.ForeignKey(Post, related_name='score')

知道发生了什么事吗?

1 个答案:

答案 0 :(得分:1)

flush仅删除数据,而不删除数据库。 如果您想删除数据库,则必须手动执行,例如使用SQL:DROP DATABASE databasename并重新运行migrate