“no such table” error on Heroku after django syncdb passed

前端 未结 4 689
日久生厌
日久生厌 2021-02-04 13:31

I\'m trying to deploy my Django application to Heroku. The migrations are in my local Git. When I try:

git push heroku master
heroku run python manage.py syncdb
         


        
4条回答
  •  被撕碎了的回忆
    2021-02-04 14:12

    You must not use sqlite3 on Heroku.

    sqlite stores the database as a file on disk. But the filesystem in a Heroku dyno is not persistent, and is not shared between dynos. So, when you do heroku run python manage.py migrate, Heroku spins up a new dyno with a blank database, runs the migrations, then deletes the dyno and the database. The dyno that's running your site is unaffected, and never gets migrated.

    You must use one of the Heroku database add-ons. There is a free tier for Postgres. You should use the dj-database-url library to set your database settings dynamically from the environment variables which Heroku sets.

    Also, for the same reason, you must do manage.py makemigrations locally, commit the result to git, then push to Heroku.

提交回复
热议问题