﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20704	"DATABASE_ROUTERS : ImproperlyConfigured ""cannot import name connection"""	artscoop	nobody	"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.
}}}"	Bug	closed	Database layer (models, ORM)	1.5	Normal	worksforme	router		Unreviewed	0	0	0	0	0	0
