I create own model user but can't authenticate it like in admin user
# myapss/models.py
from django.db import models
from django.contrib.auth.hashers import make_password, check_password
from django.db.models.manager import Manager
class MyOwnManager(Manager):
...
class MyOwnUser(models.Model):
username = models.CharField(max_length=50, unique=True)
password = models.CharField(max_length=255)
...
objects = MyOwnManager()
I want to authenticate this model without using AbstractUser or AbstractBaseUser
#myapps/views.py
from .models import MyOwnUser
def login(request):
# Authentication
https://docs.djangoproject.com/en/3.2/topics/auth/customizing/#substituting-a-custom-user-model
https://testdriven.io/blog/django-custom-user-model/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.