DATABASE_ROUTERS : ImproperlyConfigured "cannot import name connection"
|Reported by:||artscoop||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.5|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
This bug occurs also on other versions of Django.
I have a Django project which usually works well.
Today I tried to introduce the use of another database. (one is PostgreSQL, the new one is SQLite)
I've setup my settings.py as follows :
DATABASE_ROUTERS = ['engine.db.routers.custom.Router',]
The path to the router is fine, because changing it to a non-existing one raises a correct error. The router inherits from object, and defines the 4 functions shown in the Django documentation. The
allow_syncdb members return True (tried with None),
db_for_read return a database name or None.
I have properly defined my
However, trying to syncdb throws
File "/home/artscoop/virtualenv/project/lib/python2.7/site-packages/django/db/__init__.py", line 16, in <module> router = ConnectionRouter(settings.DATABASE_ROUTERS) File "/home/artscoop/virtualenv/project/lib/python2.7/site-packages/django/db/utils.py", line 117, in __init__ raise ImproperlyConfigured('Error importing database router %s: "%s"' % (klass_name, e)) django.core.exceptions.ImproperlyConfigured: Error importing database router Router: "cannot import name connection"
No answer in any site could resolve this problem.
The dubious advice to add
from django.db import connections leads to another exception
File "/home/steve/virtualenv/project/lib/python2.7/site-packages/django/db/backends/dummy/base.py", line 15, 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.
Change History (7)
comment:1 Changed 3 years ago by
|Patch needs improvement:||unset|