Django South. Heroku KeyError: 'default'

I am new to Heroku, so I tried to follow the instructions literally, and I lost this error. So, when I turned on the settings.py configurations written in the “Getting Started with Django on Heroku” section, I can no longer start the local server if I do not comment on the South from my installed applications.

This is mistake:

 from south.db import DEFAULT_DB_ALIAS
 File "/home/alejandro/Proyectos/olenv/local/lib/python2.7/site-packages/south/db/__init__.py", line 83, in <module>
 db = dbs[DEFAULT_DB_ALIAS]
 KeyError: 'default'

These are the relevant settings in settings.py:

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'dbolib',
    'USER': 'alejandro',
    'PASSWORD': 'zzzzz'
}
}

 # --- HEROKU --- #
 # Parse database configuration from $DATABASE_URL
 import dj_database_url
 DATABASES['default'] = dj_database_url.config()

Perhaps this should be so, because the South is a tool for production, and therefore it conflicts with Geroku. Maybe not, since Im new for Heroku, any clarification will help.

Edit When I comment on the South and try to run syncdb, I will remember this error:

File "/home/alejandro/Proyectos/olenv/local/lib/python2.7/site-packages/django/db/backends/dummy/base.py", line 15, in complain
raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

requirements.txt:

Django==1.6
South==0.8.4
argparse==1.2.1
dj-database-url==0.3.0
dj-static==0.0.5
django-crispy-forms==1.4.0
django-debug-toolbar==1.2
django-endless-pagination==2.0
django-extensions==1.3.5
django-toolbelt==0.0.1
gunicorn==18.0
psycopg2==2.5.2
pystache==0.5.4
six==1.6.1
sqlparse==0.1.11
static==1.0.2
wsgiref==0.1.2
+4
1

South INSTALLED_APPS, python manage.py syncdb ?

, , default dj_database_url settings.py. Heroku, DATABASE_URL, dj_database_url . , , . , South , , ( , South __init__). , , .

. DATABASE_URL . , , DATABASE_URL 'postgres://alejandro:zzzzz@localhost/dbolib'. - - , , Heroku , , dj_database_url. , dj_database_url if, True, Heroku False, .

EDIT:

, , - :

dj_database_url. , : DATABASES :

import dj_database_url
DATABASES = {}
DATABASES['default'] = dj_database_url.config()

, dj_database_url. . ( ) . , , :

if len(DATABASES['default']) == 0:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2',
            'NAME': 'dbolib',
            'USER': 'alejandro',
            'PASSWORD': 'zzzzz'
    }
}

, - [ ], , , .

, . , . , DATABASE_URL , dj_database_url , .

+7

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


All Articles