I started a new Django project, using Django 1.8. I need MongoDB as a database, so I used mongoengine. The relevant section of my settings.py file is below:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.dummy'
}
}
from mongoengine import connect
if 'test' in sys.argv:
from database_settings import TEST_DATABASE_PARAMS
connect(
TEST_DATABASE_PARAMS['db_name'],
username=TEST_DATABASE_PARAMS['username'],
password=TEST_DATABASE_PARAMS['password'],
port=TEST_DATABASE_PARAMS['port']
)
else:
from database_settings import DATABASE_PARAMS
connect(
DATABASE_PARAMS['db_name'],
username=DATABASE_PARAMS['username'],
password=DATABASE_PARAMS['password'],
port=DATABASE_PARAMS['port']
)
The DATABASE_PARAMS and TEST_DATABASE_PARAMS dictionaries contain the correct database connection parameters - I checked. When I run
python manage.py test
however, I get the following error:
Traceback (most recent call last):
File "/home/p/projects/myproj/virtualenv/local/lib/python2.7/site-packages/django/test/testcases.py", line 942, in setUpClass
if not connections_support_transactions():
File "/home/p/projects/myproj/virtualenv/local/lib/python2.7/site-packages/django/test/testcases.py", line 907, in connections_support_transactions
for conn in connections.all())
File "/home/p/projects/myproj/virtualenv/local/lib/python2.7/site-packages/django/test/testcases.py", line 907, in <genexpr>
for conn in connections.all())
File "/home/p/projects/myproj/virtualenv/local/lib/python2.7/site-packages/django/utils/functional.py", line 60, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/p/projects/myproj/virtualenv/local/lib/python2.7/site-packages/django/db/backends/base/features.py", line 216, in supports_transactions
with self.connection.cursor() as cursor:
File "/home/p/projects/myproj/virtualenv/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 164, in cursor
cursor = self.make_cursor(self._cursor())
File "/home/p/projects/myproj/virtualenv/local/lib/python2.7/site-packages/django/db/backends/dummy/base.py", line 21, in complain
raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
What's interesting is that this error doesn't occur when I start the Django shell, create a model object, and persist it into the MongoDB database. It works. The actual website also works fine. This happens only when running test.
Is this related to the latest version of Django, being version 1.8? I never had these problems in previous versions of Django. Any ideas what's wrong?