继承django自带用户表

from django.contrib.auth.models import AbstractUser

class UserInfo(AbstractUser):  # settings:   AUTH_USER_MODEL = "blog.UserInfo"
    """
    用户信息
    """
    nid = models.BigAutoField(primary_key=True)
    nickname = models.CharField(verbose_name='昵称', max_length=32,null=True)
    telephone = models.CharField(max_length=11, blank=True, null=True, unique=True, verbose_name='手机号码')
    avatar = models.FileField(verbose_name='头像', upload_to='avatar', default="/avatar/default.png")
    create_time = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)

在所继承表中继承AbstractUser,同时在setting文件写入AUTH_USER_MODEL = "blog.UserInfo"
blog是INSTALL里面的app,UserInfo是对应的表

你可能感兴趣的:(继承django自带用户表)