models.py
868 Bytes
# coding: utf-8
from django.db import models
from django.contrib.auth.models import AbstractUser
# 数据库表结构
class SysUser(models.Model):
'''
django.contrib.auth.models.User 默认User类字段太少,用AbstractUser
自定义一个User类,增加字段
'''
suid = models.IntegerField(u'uid', primary_key=True)
user_name = models.CharField(u'用户名', max_length=20, unique=True)
level = models.IntegerField(u'level')
create_time = models.DateTimeField()
status = models.IntegerField()
last_login_ip = models.CharField(max_length=20)
last_login_time = models.DateTimeField()
USERNAME_FIELD = 'user_name'
REQUIRED_FIELDS = ['suid']
def __unicode__(self):
return self.user_name
class Meta(object):
db_table = 'sys_user'
verbose_name = verbose_name_plural = u'用户'