﻿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
12767	Problem running syncdb with a multi-db router that restricts auth to a single database	Russell Keith-Magee	nobody	"Via Klemens Mantzos on django-users:

If i do
{{{
python manage.py syncdb --database=default
}}}
before i sync the users database this error comes up (which seems ok to me):
{{{
django.db.utils.DatabaseError: (1146, ""Table 'multidb_user.auth_permission' doesn't exist"")
}}}
but if i do this:
{{{
python manage.py syncdb --database=users
}}}
i get that every time (no matter if django_content_type already exists in the default db or not):
{{{
django.db.utils.DatabaseError: (1146, ""Table 'multidb_user.django_content_type' doesn't exist"")
}}}

== Router config ==
{{{
# don't know but OtherRouter is maybe obsolete.
DATABASE_ROUTERS = ['dbrouter.AuthRouter', 'dbrouter.OtherRouter']
}}}

== project/dbrouter.py ==
{{{
class AuthRouter(object):
  """"""A router to control all database operations on models in
  the contrib.auth application""""""

  ....

  def allow_syncdb(self, db, model):
      ""Make sure the auth app only appears on the 'credentials' db""
      if db == 'users':
          return model._meta.app_label == 'auth'
      elif model._meta.app_label == 'auth':
          return False
      return None


class OtherRouter(object):
  """"""A router that sets up a simple master/slave configuration""""""

  ...

  def allow_syncdb(self, db, model):
      ""Explicitly put all models on all databases.""
      return True
}}}"	Bug	closed	Database layer (models, ORM)	dev	Normal	duplicate		klemens@… kmpm@… jonj@… digitalxero@… mmitar@…	Accepted	1	0	0	1	0	0
