[Django]-Heroku created table but when I'll migrate, he says that doesn't created

2👍

local_settings.py

import os

SITE_ROOT = os.path.dirname(__file__)

DEBUG = True
TEMPLATE_DEBUG = DEBUG

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(SITE_ROOT, 'data.sqlite3'),
    }
}

In your gitignore, add this:

project_name/local_settings.py
*.sqlite3

6👍

Tested on Django 1.9

settings.py

in_heroku = False
if 'DATABASE_URL' in os.environ:
    in_heroku = True

import dj_database_url
if in_heroku:
    DATABASES = {'default': dj_database_url.config()}
else:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
        }
    }

Then run:

heroku addons:create heroku-postgresql:hobby-dev
sudo apt-get intall postgresql libpq-dev
pip install dj-database-url psycopg2
pip freeze >requirements.txt
git add .
git commit -m 'msg'
git push heroku master
heroku run python manage.py migrate

References:

Leave a comment