扩展User

增加 User Model

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class CustomUser(AbstractUser):
# todo: keep field below:
# todo username first_name last_name email is_staff is_active date_joined
# 手机
phone = models.CharField(max_length=11)
# 账户类型 0:普通 1:微信 2:QQ 3:新浪
type = models.IntegerField(default=0)
# 用户等级 0:普通
level = models.IntegerField(default=0)
# 上次登陆时间
last_login = models.DateTimeField(blank=True, null=True)
# 登陆次数
login_times = models.IntegerField(default=0)

objects = UserManager()

def __str__(self):
return self.username

配置setting.py

AUTH_USER_MODEL = ‘app_name.CustomUser’