Import AbstractUser, And make the user model class inherit it .
from django.contrib.auth.models import AbstractUser
from django.db import models
from db.base_model import BaseModel
class User(AbstractUser, BaseModel):
""" User model class """
class Meta:
db_table = 'df_user'
verbose_name = ' user '
verbose_name_plural = verbose_name
Before migrating the database, add the following code to the configuration file .
# django The model class used by the authentication system
AUTH_USER_MODEL = 'user.User'
Because of the use of django Built in user authentication , When saving user information to the database , have access to create_user()
user = User.objects.create_user(username, email, password)