这怎么可能?我做了python manage.py flush
删除了数据库。我也卸载并重新安装了django。然后我做了makemigrations
和migrate
。但我在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')
知道发生了什么事吗?
答案 0 :(得分:1)
flush
仅删除数据,而不删除数据库。
如果您想删除数据库,则必须手动执行,例如使用SQL:DROP DATABASE databasename
并重新运行migrate
。