This is a very tricky problem unless you designate exactly one of your projects to be the "master" of the custom user model. Otherwise, you might have competing migrations against the same database table. Once you decide which project will be the master, the non-master projects should have a separate entry in DATABASES
that will connect them to the central user database
DATABASES = {
'default': ...
'users': {
'HOST': 'central-host.example.com',
'NAME': 'central-users',
...
}
}
DATABASE_ROUTERS = 'my_app.database_router'
In your router, you can specify that the User model should be read from the central-users database:
class Router(object):
def db_for_read(self, model, **hints):
if model.__name__ == 'CustomUserModel':
return 'users'
return 'default'
def db_for_write(self, model, **hints):
if model.__name__ == 'CustomUserModel':
return 'users'
return 'default'