Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use my custom model and not the Django user model? #898

Open
paulocoutinhox opened this issue Mar 30, 2024 · 0 comments
Open

How to use my custom model and not the Django user model? #898

paulocoutinhox opened this issue Mar 30, 2024 · 0 comments

Comments

@paulocoutinhox
Copy link

paulocoutinhox commented Mar 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant