https://devcenter.heroku.com/articles/django-app-configuration
settings.py
import django_heroku .... .... # Activate Django-Heroku django_heroku.settings(locals())
And when I run it with debug mode in local web app, it's running well.
But it always shows error when I deploy it to Heroku.
"relation "auth_user" does not exist"
Heroku debug:
tail log command in Heroku:
tail log command in Heroku:
heroku logs -t -a [heroku_app_name]
Then I found it always shows datatable does not exists.
2018-07-14T13:17:25.115046+00:00 app[web.1]: Internal Server Error: /api-token-auth/
2018-07-14T13:17:25.115060+00:00 app[web.1]: Traceback (most recent call last):
2018-07-14T13:17:25.115062+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
2018-07-14T13:17:25.115063+00:00 app[web.1]: return self.cursor.execute(sql, params)
2018-07-14T13:17:25.115065+00:00 app[web.1]: psycopg2.ProgrammingError: relation "auth_user" does not exist
2018-07-14T13:17:25.115067+00:00 app[web.1]: LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user...
2018-07-14T13:17:25.115068+00:00 app[web.1]: ^
Solution:
It seems database not been created.
So I run migrate command to Heroku:
heroku run python manage.py migrate -a [heroku_app_name]
And it works finally.
Root cause:
In local app build, the SQL connects to a existed Heroku data app.
But when I deploy it to Heroku web app, it will create another Heroku data app.
So Django migrations is prerequisite of deploying to Heroku.
Root cause:
In local app build, the SQL connects to a existed Heroku data app.
But when I deploy it to Heroku web app, it will create another Heroku data app.
So Django migrations is prerequisite of deploying to Heroku.
沒有留言:
張貼留言