I have seen importing User model in Django project as follows
from django.contrib.auth.models import User
and
from django.conf import settings.AUTH_USER_MODEL as User
What difference does these make? I think in both cases we import same user
Both are same. Sometimes you want to use another model for Auth's project. Then you can define your model in settings.py file. like this:
AUTH_USER_MODEL = 'membership.User'
and in membership app, you have a model named User
class User(AbstractBaseUser, PermissionsMixin):
full_name = models.CharField(
max_length=100,
blank=True,
null=True
)
username = models.CharField(
max_length=50,
null=True,
blank=True
)
email = models.EmailField(
db_index=True,
unique=True
)
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.