1. 我开发环境是 python34 django 1.8.1
2. 本地用数据库是 sqlite3, heroku 用到 postgres
3. 我部署在heroku上是给另一个人测试用的,由于一直变更需求,表结构要变
4. 我情景是,我之前的工程已经在 herok 上跑,没有问题, 然后我在 model中添加了一个 class Message(models.Model): user = models.ForeignKey('GameUser') 而 GameUser 是原来有的一个model
5. 然后我push了,然后在heroku 上执行
python manage.py makemigrations
python manage.py migrate
然后进入 python manage.py shell , 导入model后, 执行 Message.objects.all() ,提示上面的提问里错误
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/app/.heroku/pythonb/python3.4/site-packages/django/models/query.py", line 138, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
File "/app/.heroku/pythonb/python3.4/site-packages/django/models/query.py", line 162, in __iter__
self._fetch_all()
File "/app/.heroku/pythonb/python3.4/site-packages/django/models/query.py", line 965, in _fetch_all
self._result_cache = list(self.iterator())
File "/app/.heroku/pythonb/python3.4/site-packages/django/models/query.py", line 238, in iterator
results = compiler.execute_sql()
File "/app/.heroku/pythonb/python3.4/site-packages/django/modelsl/compiler.py", line 837, in execute_sql
cursor.execute(sql, params)
File "/app/.heroku/pythonb/python3.4/site-packages/django/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/app/.heroku/pythonb/python3.4/site-packages/django/utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/app/.heroku/pythonb/python3.4/site-packages/django/utils/six.py", line 658, in reraise
raise value.with_traceback(tb)
File "/app/.heroku/pythonb/python3.4/site-packages/django/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "dbmanager_message" does not exist
LINE 1: ..."msg_code", "dbmanager_message"."parameters" FROM "dbmanager...
然而执行 GameUser.objects.all() 并不会报错