Dica 14 - Django Custom User com e-mail

User

https://github.com/django/django/blob/70c945d6b31b41b320e57088702077864428fdc0/django/contrib/auth/models.py#L405

AbstractUser

https://github.com/django/django/blob/70c945d6b31b41b320e57088702077864428fdc0/django/contrib/auth/models.py#L334

AbstractBaseUser

https://github.com/django/django/blob/70c945d6b31b41b320e57088702077864428fdc0/django/contrib/auth/base_user.py#L56

Extending User Model Using a Custom Model Extending AbstractBaseUser

https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html#abstractbaseuser

Django autenticação e login com email - Django login email

https://youtu.be/dXdMD3LBUvA

Crie a app accounts

cd backend
python ../manage.py startapp accounts
cd ..

Edite settings.py

# settings.py

AUTH_USER_MODEL = 'accounts.User'

INSTALLED_APPS = [
    'backend.accounts',  # <<<
    'django.contrib.admin',
    ...
]

Edite accounts/apps.py

Edite accounts/models.py

Edite accounts/admin.py

Edite accounts/managers.py

Edite accounts/tests.py

Erro

Delete o banco de dados e recrie novamente.

Last updated

Was this helpful?