"no such table" error on Heroku after django syncdb passed

What version of django you are using..?

If you are using django>=1.7 you need to run migrate

After adding models you need to do python manage.py makemigrations then python manage.py migrate

If your project already contain migrations you can directly run python manage.py migrate command.

If you miss any step mentioned above please do that.


You can use postgresql:

In settings.py add(at the end of file):

# ie if Heroku server
if 'DATABASE_URL' in os.environ:
    import dj_database_url
    DATABASES = {'default': dj_database_url.config()}

In requirements.txt add:

dj-database-url 
psycopg2

Now you can run: heroku run python manage.py migrate


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.


pip install django-heroku

Add import django_heroku at top of file settings.py

Place django_heroku.settings(locals()) at the very bottom of settings.py

It will automatically configure your db. You can learn more on their website