Can I implement separate user authentication and models for two apps in django project?

In this django project I have two separate applications that I need to keep user account information separate. For example, if a person creates an account for app A, I need them to be able to make a separate account (with the possibility of using the same unique email for account creation) for app B. At this moment in time, it seems as though there is no way for me to handle having two separate auth models for two separate users. I am wondering what the django workaround for this might be, or if I am misunderstanding the problem in some way?

Here is an example user model that would work for both application A and B, but would need separate tables or models for authentication and account creation:

class GenericUser(AbstractUser): """abstract user class for user authentication""" firstname = models.CharField('First Name', blank=True, max_length=100) lastname = models.CharField('Last Name', blank=True, max_length=100) email = models.CharField('Email', unique=True, max_length=100)

class Meta:
    permissions = (
        ("some-permission", "some-description"),
    )

First I tried creating two separate user entities in the models.py file in my django project, however when I finished doing this, there was nowhere to put the second user model in the settings.py folder. This is where I am stuck now.

May be you are looking for this .. django support multiple authentication model. in order to do this you need to create a custom authentication backend by inherit from 'django.contrib.auth.backends.BaseBackend' (you can specify different user model there, I think ) and specify the authentication model in the settings.py of the project. For more information. check this doc

Back to Top