Syncdb issues after building Heroku Django app

I am creating a Django application on Heroku using https://devcenter.heroku.com/articles/django and I encountered the heroku run python manage.py syncdb error below

 ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details. 

I get the same error while syncing locally. I read all the threads in StackOverflow, but nothing solved this problem. Relevant parts of settings.py:

 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'NAME': '', # Or path to database file if using sqlite3. # The following settings are not used with sqlite3: 'USER': '', 'PASSWORD': '', 'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. 'PORT': '', # Set to empty string for default. } } import dj_database_url DATABASES['default'] = dj_database_url.config() # Honor the 'X-Forwarded-Proto' header for request.is_secure() SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # Allow all host headers ALLOWED_HOSTS = ['*'] # Static asset configuration import os BASE_DIR = os.path.dirname(os.path.abspath(__file__)) STATIC_ROOT = 'staticfiles' STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), 
+4
source share
2 answers

I'm not sure why the textbook is silent about this - I often come across a similar question, but here are the steps I took that solved the problem. It is also worth reading the Postgres documentation - https://devcenter.heroku.com/articles/heroku-postgresql

1) Create a Postgres database using heroku addons | grep POSTGRES heroku addons | grep POSTGRES in terminal

2) Connect DB to the application - heroku addons:add heroku-postgresql:dev

3) Promote the URL of the database URL: heroku pg:promote HEROKU_POSTGRESQL_RED_URL

4) Add this to your settings.py:

DATABASES['default'] = dj_database_url.config(default=os.environ.get('DATABASE_URL'))

+9
source

In your settings, put:

 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # Or another database 'NAME': 'database.db', 'USER': '', 'PASSWORD': '', 'HOST': '', 'PORT': '', } } 
-one
source

Source: https://habr.com/ru/post/1494819/


All Articles