pennersr / django-allauth

Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication.

Home Page:https://allauth.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use my custom model instead of django user model?

paulocoutinhox opened this issue · comments

Hi,

I want use my custom model:
https://github.com/paulocoutinhox/pyaa/blob/main/account/models.py#L17

Instead of Django user model.

But, only for "site" auth/login and not for the "admin".

The "admin" i want the default things with user model.

What i need do?

I already implement the create pipeline and it is creating:

import uuid

from language.models import Language
from main import settings

from ..enums import CustomerStatus
from ..models import Customer


def create_user(strategy, details, backend, user=None, *args, **kwargs):
    if user:
        return {"is_new": False}
    else:
        is_new = True
        email = details.get("email")

        try:
            customer = Customer.objects.get(email=email)
        except Customer.DoesNotExist:
            language = Language.objects.first()

            customer = Customer(
                name=details.get("fullname", ""),
                email=email,
                language=language,
                status=CustomerStatus.ACTIVE,
                timezone=settings.DEFAULT_TIME_ZONE,
            )

            customer.setup_password_data(password=str(uuid.uuid4()))
            customer.setup_initial_data()
            customer.save()

        return {"is_new": is_new, "user": customer}

But i need now the association and the other things.

What i need do?

Thanks.