扩展User 发表于 2017-10-19 | 分类于 python , django , model 增加 User Model123456789101112131415161718class 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.pyAUTH_USER_MODEL = ‘app_name.CustomUser’