django-tenant-schemas
django-tenant-schemas copied to clipboard
Seperate custom user accounts for public and tenants sites
Hi,
I am trying to implement separate admin and authentication systems for the public and tenant sites. For the public site I want users to be able to register with their email address, after clicking a confirmation link in an email sent to them, a new tenant site is created.
Within the tenant site I want them to be able to freely create as many user accounts as they like, based around a traditional username this time.
Both these account systems are custom, not the normal django auth User account (although both are based on it). I have set up the tenant system so that the public and tenant settings are separate and have set the appropriate AUTH_USER_MODEL in the relevant settings file.
Unfortunately the initial migration always fails. The failure is at the point of applying the admin initial migration: psycopg2.ProgrammingError: relation "system_account" does not exist
I can see this is a problem with having two separate user authentication models, however as the tenant system is in effect creating separate databases (schemas) for each, surely this should be possible.
Can you let me know if this is possible and if so give me some pointers as to how I need to configure it.
Thanks,
Paul
Just a quick update to this, the problem seems to be with the way django_tenant_schemas handles or doesn’t handle the AUTH_USER_MODEL. If I create settings files without it, then everything migrates as it should (obviously in this case I'm pointing the public and tenant [for want of a better description as I'm not using the tenant system in this test] settings at separate databases) but it works perfectly. I notice there are a lot of people having problems using a custom user model with django_tenant_schemas could you perhaps provide an example of how to successfully configure it.
Hi,
Did you solve this problem? I have the same problem here in my project, and I'm stuck in these bug...
Any fix for this? I used @pydanny 's Cookiecutter template and can't manage to get the Authentication working.
Can you write a unit test that exhibits the behaviour?
I am using custom auth models in my DTS projects, I don't recall having encountered this.
Not wanting to be me too but, I have same setup as @spoetnik . I am having problem getting migrations working. The way I have setup is something like this.
SHARED_APPS = ['tenant_schemas', 'client']
TENANT_APPS = [
'django.contrib.admin',
# Default Django apps:
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'core' #This has custom user model and some other models
]
AUTH_USER_MODEL = 'core.User'
For migrations I issue this command
python manage.py makemigrations client
python manage.py migrate_schemas --shared
Migrations are completed successfully. I then create one tenant in public schema. I then follow it up with migrations for other local apps. One of this local app is core
which has custom user model. The commands I used are
python manage.py makemigrations core
python manage.py migrate_schemas
It gives me following exception
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency core.0001_initial on database 'default'.
Can someone point out defect in this process? I am stuck.
Any Solution on this issue ?
Try https://github.com/Corvia/django-tenant-users/