DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'db1', 'USER': 'root', }, 'users': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'db2', 'USER': 'root', }, } #and router class AuthRouter(object): """A router to control all database operations on models in the contrib.auth application""" def db_for_read(self, model, **hints): "Point all operations on auth models to 'credentials'" if model._meta.app_label == 'auth': return 'users' return None def db_for_write(self, model, **hints): "Point all operations on auth models to 'credentials'" if model._meta.app_label == 'auth': return 'users' return None def allow_relation(self, obj1, obj2, **hints): "Allow any relation if a model in Auth is involved" return True if obj1._meta.app_label == 'auth' or obj2._meta.app_label == 'auth': return True return None 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