[Answer]-One Django Project, Multiple Settings.py

1👍

you dont need to set two AUTH_USER_MODEL = 'myapp.MyUser' ‘s or two settings for this purpose which probabyly would work but this is not the level this logic belongs to. (settings is already in deployment level e.g. running multiple websites on the same codebase and same databse etc etc…)

what I would recommend is something simple:

# settings.py
AUTH_USER_MODEL = 'yourapp.CustomUser'

# yourapp's models.lpy
from django.contrib.auth.models import User
class CustomUser(models.Model):
    user = models.OneToOneField(User, related_name="customuser")
    crm_staff = models.Boolean(default=False)
    # ...

and depending on crm_staff, the user is either crm-user or just an external user. I set the default value of crm_staff to False, so that you have to give it explicitly everytime a new user comes in, but only if user is a crm staff, then you need to set the field to True

keep it as simple as possible, you say thanks to yourself for this later..

Leave a comment