设置django自带的user表

一、使用

from django.contrib.auth.models import AbstractUser
引用这个类,继承这个类

class UserProfile(AbstractUser):
    nick_name = models.CharField(max_length=50,verbose_name="昵称",default="")
    birday = models.DateField(verbose_name="生日",null=True,blank=True)
    gender = models.CharField(max_length=6,choices=(("male","男"),("female","女")),default="female")
    address = models.CharField(max_length=100, default="")
    mobile = models.CharField(max_length=11,null=True,blank=True)
    image = models.ImageField(upload_to='image/%Y/%m',default="image/default.png",max_length=100)

    class Meta:
        verbose_name = "用户信息"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.username

在setting中创建AUTH_USER_MODEL = "users.UserProfile"

你可能感兴趣的:(设置django自带的user表)