2015-06-26 07:59:53 +00:00
|
|
|
# coding=utf-8
|
|
|
|
from django.db import models
|
|
|
|
from django.contrib.auth.models import AbstractBaseUser
|
|
|
|
|
|
|
|
|
|
|
|
class AdminGroup(models.Model):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2015-06-29 04:43:17 +00:00
|
|
|
class UserManager(models.Manager):
|
|
|
|
use_in_migrations = True
|
|
|
|
|
|
|
|
def get_by_natural_key(self, username):
|
|
|
|
return self.get(**{self.model.USERNAME_FIELD: username})
|
|
|
|
|
|
|
|
|
2015-06-26 07:59:53 +00:00
|
|
|
class User(AbstractBaseUser):
|
2015-07-18 09:17:33 +00:00
|
|
|
# 用户名
|
2015-06-26 07:59:53 +00:00
|
|
|
username = models.CharField(max_length=30, unique=True)
|
2015-07-18 09:17:33 +00:00
|
|
|
# 真实姓名
|
|
|
|
real_name = models.CharField(max_length=30, blank=True, null=True)
|
2015-08-05 12:11:25 +00:00
|
|
|
# 用户邮箱
|
|
|
|
email = models.EmailField(max_length=254, blank=True, null=True)
|
2015-08-06 04:25:16 +00:00
|
|
|
# 0代表不是管理员 1是普通管理员 2是超级管理员
|
|
|
|
admin_type = models.IntegerField(default=0)
|
2015-06-26 07:59:53 +00:00
|
|
|
|
2015-06-29 04:43:17 +00:00
|
|
|
USERNAME_FIELD = 'username'
|
|
|
|
REQUIRED_FIELDS = []
|
|
|
|
|
|
|
|
objects = UserManager()
|
|
|
|
|
2015-06-26 07:59:53 +00:00
|
|
|
class Meta:
|
|
|
|
db_table = "user"
|