1、在models编写你的user类,继承AbstractUser类,并设计你需要的字段:
from django.contrib.auth.models import AbstractUser # 用户信息表 class UserProfile(AbstractUser): nick_name = models.CharField(max_length=20, verbose_name=u'昵称', default=u'新用户') birthday = models.DateField(verbose_name=u'生日', null=True, blank=True) gender = models.CharField(choices=(('men', u'男'), ('woman', u'女')), max_length=8, default='woman' ) address = models.CharField(max_length=100, default=u'火星村', verbose_name=u'邮箱地址') mobile = models.CharField(max_length=11, verbose_name='联系方式', null=True, blank=True, default='') image = models.ImageField(upload_to='var/image', default='', max_length=100, null=True, blank=True) class Meta: verbose_name = u'用户' verbose_name_plural = verbose_name def __unicode__(self): return self.username
2、需要在setting中配置,默认使用我们自定义的user表:
# 自定义user表 AUTH_USER_MODEL = 'users.UserProfile'
3、更新同步数据库,删除django的user表:
python manage.py makemigrations users
python manage.py migrate