#20704: DATABASE_ROUTERS : ImproperlyConfigured "cannot import name connection"
----------------------------------------------+--------------------
Reporter: artscoop | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: 1.5
Severity: Normal | Keywords: router
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
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 :
{{{#!python
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_relation}}} and {{{allow_syncdb}}} members return True (tried
with None), {{{db_for_write}}} and {{{db_for_read}}} return a database
name or None.
I have properly defined my {{{DATABASE}}} setting.
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.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/20704>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.90f32d1811cb94c52d0a6e274c5af238%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.