您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。