我在Django中有一个应用程序,我将其部署在Heroku上。 部署工作正常,但我的模型数据库没有迁移。
部署后,我再次在本地运行:
python manage.py makemigrations
python manage.py migrate
接下来,我执行以下操作:
heroku run python manage.py makemigrations
heroku run python manage.py migrate
在我启动服务器并等待后,它能够正常运行。
heroku run python manage.py runserver
我有3个模型:
cliente(客户),categoria(类别),produto(产品)
produto(产品)
拥有到categoria(类别)
的外键。因此,本地我有3个数据库:
produtos_produto(产品)
,produtos_categoria(类别)
,cliente(客户)
。
我在本地和heroku上都使用PostgreSQL
作为数据库。
但是在heroku上,我没有任何这些数据库。
当我运行服务器时,在浏览器中我得到了以下答案:
ProgrammingError at /
relation "produtos_categoria" does not exist
LINE 1: ...ia"."descricao", "produtos_categoria"."logo" FROM "produtos_...
^
Request Method: GET
Request URL: http://redewebsite.herokuapp.com/
Django Version: 1.9.2
Exception Type: ProgrammingError
Exception Value:
relation "produtos_categoria" does not exist
LINE 1: ...ia"."descricao", "produtos_categoria"."logo" FROM "produtos_...
^
Exception Location: /app/.heroku/python/lib/python2.7/site-packages/django/db/backends/utils.py in execute, line 64
Python Executable: /app/.heroku/python/bin/python
Python Version: 2.7.11
Python Path:
['/app',
'/app/.heroku/python/bin',
'/app/.heroku/python/lib/python2.7/site-packages/setuptools-19.6-py2.7.egg',
'/app/.heroku/python/lib/python2.7/site-packages/pip-8.0.2-py2.7.egg',
'/app',
'/app/.heroku/python/lib/python27.zip',
'/app/.heroku/python/lib/python2.7',
'/app/.heroku/python/lib/python2.7/plat-linux2',
'/app/.heroku/python/lib/python2.7/lib-tk',
'/app/.heroku/python/lib/python2.7/lib-old',
'/app/.heroku/python/lib/python2.7/lib-dynload',
'/app/.heroku/python/lib/python2.7/site-packages']
Server time: Sex, 4 Mar 2016 17:50:43 +0000