aksh_sharma
aksh_sharma

Reputation: 55

Using postgresql database with Django for heroku

after applying all migration using heroku run python manage.py migrate. it gives this error. I had switched to postgresql. But migration are still applied only on sqlite3.

OperationalError at /
no such table: shastri_occasion
Request Method: GET
Request URL:    https://bdsharma.herokuapp.com/
Django Version: 3.1.1
Exception Type: OperationalError
Exception Value:    
no such table: shastri_occasion
Exception Location: /app/.heroku/python/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py, line 413, in execute
Python Executable:  /app/.heroku/python/bin/python
Python Version: 3.6.12
Python Path:    
['/app/.heroku/python/bin',
 '/app',
 '/app/.heroku/python/lib/python36.zip',
 '/app/.heroku/python/lib/python3.6',
 '/app/.heroku/python/lib/python3.6/lib-dynload',
 '/app/.heroku/python/lib/python3.6/site-packages']
Server time:    Fri, 11 Sep 2020 09:34:29 +0000

I had switched to postgresql. But migration are still applied only on sqlite3. This is my setting.py database setting:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'ddbp7me1o4bf',
        'USER' :'iwdvmaevgph',
        'PASSWORD' : '****************************8',
        'HOST' : '*****************8',
        'PORT' : '5432',

    }
}

Upvotes: 0

Views: 96

Answers (1)

Surya Bista
Surya Bista

Reputation: 564

You can configure the database setting like this.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'project',
        'USER': 'root',
        'PASSWORD': 'password',
        'HOST': 'localhost',
        'PORT': '',
    }
}

Upvotes: 1

Related Questions