我收到错误:
Exception Value:
no such table: hello_surname
当我尝试显示访问Surname模型的视图时
在我的models.py
中class Surname(models.Model):
created = models.DateTimeField('date created', auto_now_add=True)
name = models.CharField(max_length=35)
我尝试过运行迁移$ heroku run python manage.py migrate
输出中:
Running python manage.py migrate on ⬢ sleepy-fjord... up, run.7027
Operations to perform:
Apply all migrations: sessions, auth, hello, contenttypes, admin
Running migrations:
No migrations to apply.
Your models have changes that are not yet reflected in a migration, and so won't be applied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
然后我运行$ heroku run python manage.py makemigrations
输出:
Running python manage.py makemigrations on ⬢ sleepy-fjord... up, run.8567
Migrations for 'hello':
0002_surname.py:
- Create model Surname
当我再次运行top migrate时,它只会提供与我第一次运行它时相同的输出。好像我在这里错过了一步,但凭借输出我似乎无法自己解决。有人知道任何解决方案吗?
答案 0 :(得分:0)
您必须运行本地迁移 ,提交结果,然后在Heroku上运行迁移。