When I run python manage.py runserver
I get the following error:
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x1cc9cd0>>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 91, in inner_run
self.validate(display_num_errors=True)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 266, in validate
num_errors = get_validation_errors(s, app)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 30, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 158, in get_app_errors
self._populate()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 64, in _populate
self.load_app(app_name, True)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 88, in load_app
models = import_module('.models', app_name)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/South-0.7.6-py2.7.egg/south/models.py", line 2, in <module>
from south.db import DEFAULT_DB_ALIAS
File "/usr/local/lib/python2.7/dist-packages/South-0.7.6-py2.7.egg/south/db/__init__.py", line 81, in <module>
db = dbs[DEFAULT_DB_ALIAS]
KeyError: 'default'
Here is my settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'foureggs',
'USER': 'myuser',
'PASSWORD': 'mypass',
'HOST': '',
'PORT': '',
}
}
Here is a question with the same problem. The answer says that "there should be a database named 'default' in your settings". I'm not really following that. My db name is "foureggs" so I want to use that, obviously.
UPDATE: When I do python manage.py diffsettings
I get the following output, which doesn't look correct (pasting only the relevant DATABASE line, the rest of the settings look OK):
DATABASES = {'default': {'ENGINE': 'django.db.backends.dummy', 'TEST_MIRROR': None, 'NAME': '', 'TEST_CHARSET': None, 'TIME_ZONE': 'UTC', 'TEST_COLLATION': None, 'PORT': '', 'HOST': '', 'USER': '', 'TEST_NAME': None, 'PASSWORD': '', 'OPTIONS': {}}}
I have only one settings file in my project and it's in the app directory, which is correct. Where does the above DATABASE line come from?
UPDATE 2: I figured out what's the problem. It's these 2 extra lines I put to settings.py
as instructed by Heroku deployment guide. When I comment them out, everything works fine. Now I need to figure out why it's causing the problem.
# Parse database configuration from $DATABASE_URL
import dj_database_url
DATABASES['default'] = dj_database_url.config()
The problem is apparently not related to South, but to the DB backend.
you may start from here: "settings.DATABASES is improperly configured" error performing syncdb with django 1.4 and related questions
If the aforementioned answers not work, first of all check if psycopg2 library is installed and in your sys.path: if not please install it Psycopg2 library install instructions here.
then you can eventually change your ENGINE setting to: 'postgresql_psycopg2'; in this way you can bypass the built-in engine if for any reason it will not work.