Django. One project. Separate auth systems and templates for different apps

I have a project with the following structure:

  • main_app
  • accounts_app (stores CustomUser model)
  • my_app1
    • users_app (inside my_app1)
  • my_app2
    • users_app (inside my_app2)

The reason behind separate users_app is that I want to reuse my_app1 and my_app2 in other projects. So I want them to be as separate as possible.

I want to have a separate auth system (custom user model, registration, templates, login/logout redirect, etc) for each app. So for example, let's say I have my-app1 at url localhost:8000/my-app1/. This means that registration will be at /my-app1/signup/, login at /my-app1/login/ and login redirect goes to /my-app1/

I also want to use allauth on some or all apps. Questions:

  1. Does this project structure even make sense? (yes/no)
  2. Is it possible to have separate signup/sigin/etc templates for each app using allauth? (yes/no - link to doc?) I couldn't find the answer to this.
  3. How do I avoid DB conflicts with migrations when creating custom user for each app? Right now I'm inheriting from AbstractUser in each app's model.py, like so: class MainCustomUser(AbstractUser), class AppOneUser(AbstractUser), class AppTwoUser(AbstractUser) But that doesn't seem to work.

Answers to these questions will serve me as guidance in the right direction, right now I sort of confused myself a bit.

settings.py:

...

# django-allauth config
SITE_ID = 1
LOGIN_REDIRECT_URL = 'main_app:index'
ACCOUNT_LOGOUT_REDIRECT = 'main_app:index'
AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'allauth.account.auth_backends.AuthenticationBackend',
)

...
Back to Top