South + Django 1.4 Database error

可紊 提交于 2019-12-02 22:06:35

You don't have correct DATABASES in your settings. There should be a database named 'default'

I have the same error message but with a different cause and solution compared to the accepted answer. The short answer is adding SOUTH_DATABASE_ADAPTERS = {'default':'south.db.postgresql_psycopg2'} to settings.py.

Here is the full explanation:

Tracing to south/db/__init__.py shows that no database was detected, the reason being that my database engine name is not in the hardcoded list in south/db/__init__.py

engine_modules = {
    'django.db.backends.postgresql_psycopg2': 'postgresql_psycopg2',
    'django.db.backends.sqlite3': 'sqlite3',
    'django.db.backends.mysql': 'mysql',
    'django.db.backends.oracle': 'oracle',
    'sql_server.pyodbc': 'sql_server.pyodbc', #django-pyodbc
    'sqlserver_ado': 'sql_server.pyodbc', #django-mssql
    'firebird': 'firebird', #django-firebird
    'django.contrib.gis.db.backends.postgis': 'postgresql_psycopg2',
    'django.contrib.gis.db.backends.spatialite': 'sqlite3',
    'django.contrib.gis.db.backends.mysql': 'mysql',
    'django.contrib.gis.db.backends.oracle': 'oracle',
    'doj.backends.zxjdbc.postgresql': 'postgresql_psycopg2', #django-jython
    'doj.backends.zxjdbc.mysql': 'mysql', #django-jython
    'doj.backends.zxjdbc.oracle': 'oracle', #django-jython
}

I use postgis 2.0 on Windows and a while ago had to apply a minor patch to django's postgis backend. Because I didn't install django from source, I made a copy of the backend and applied the patch manually to that copy. So the new backend is in a different location, and that location isn't in the list of keys in South's engine_modules shown above.

Luckily, South provides a settings variable called SOUTH_DATABASE_ADAPTERS that tells South directly the actual database engine of each alias. I was able to run syncdb after inserting this line into settings.py

SOUTH_DATABASE_ADAPTERS = {'default':'south.db.postgresql_psycopg2'}

kiril

For those using Heroku, which is my case. I found this problem too, I have the default database set, as they point out in the heroku guides:

DATABASES['default'] =  dj_database_url.config()

However, the ketError 'default' error still appears. This is due to there is no database provisioned, and thus dj_database_url cannot find it and raised that confusing error.

To solve it just provision the database and promote it as explained in heroku postgresql

heroku addons:add heroku-postgresql:dev
heroku pg:promote HEROKU_POSTGRESQL_BLUE
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!