Note that there are some explanatory texts on larger screens.

plurals
  1. POdjango 1.4 database router - "cannot import name connection"
    text
    copied!<p>I'm trying to shard my database on django, but I've got strange error on a first steps.</p> <p>I made a simple db router, that dous nothing:</p> <pre><code>'''file /myproject/myapp/routers.py''' class ShardingRouter(object): def db_for_read(self, model, **hints): return 'default' def db_for_write(self, model, **hints): return 'default' def allow_relation(self, obj1, obj2, **hints): return 'default' def allow_syncdb(self, db, model): return 'default' </code></pre> <p>I added in settings.py:</p> <pre><code>DATABASE_ROUTERS = ['myproject.myapp.routers.ShardingRouter',] </code></pre> <p>I'm getting this error:</p> <pre><code>Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 219, in __call__ self.load_middleware() File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware mod = import_module(mw_module) File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/hosting/myproject/myproject/middleware.py", line 10, in &lt;module&gt; from django.contrib.sites.models import Site File "/usr/local/lib/python2.7/dist-packages/django/contrib/sites/models.py", line 1, in &lt;module&gt; from django.db import models File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 16, in &lt;module&gt; router = ConnectionRouter(settings.DATABASE_ROUTERS) File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 116, in __init__ raise ImproperlyConfigured('Error importing database router %s: "%s"' % (klass_name, e)) ImproperlyConfigured: Error importing database router ShardingRouter: "cannot import name connection" </code></pre> <p>What 'connection'? What does it mean? Can't find, where is the problem((</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload