1、自定义用户表
from django.db import models from django.contrib.auth.models import AbstractUser # Create your models here. class UserProfile(AbstractUser): ##引用Django内置的AbstractUser表,并添加下列字段 nick_name = models.CharField(max_length=50,default="",verbose_name=u"昵称") birday = models.DateField(verbose_name=u"生日",null=True,blank=True) gender = models.CharField(max_length=10,choices=(("male",u"男"),("female",u"女")),default="female") address = models.CharField(max_length=100,default=u"",verbose_name='地址') mobile = models.CharField(max_length=11,null=True,blank=True,verbose_name='手机号码') p_w_picpath = models.ImageField(upload_to="p_w_picpath/%Y/%m",default=u"p_w_picpath/default.png",max_length=100) class Meta: verbose_name = u"用户信息" verbose_name_plural = verbose_name def __unicode__(self): return self.username
2、在settings注册APP,并配置用户表model参数AUTH_USER_MODEL
INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'users' ] AUTH_USER_MODEL = "users.UserProfile"
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。