1.在app下的forms.py文件下:
# coding=utf-8from datetime import datetime from django.db import modelsfrom django.contrib.auth.models import AbstractUser # Create your models here. ‘‘‘用户表‘‘‘ class UserProfile(AbstractUser): name = models.CharField(max_length=50, verbose_name=u‘姓名‘, null=True, blank=True) birthday = models.DateTimeField(verbose_name=u‘出生年月‘, null=True, blank=True) gender = models.CharField(max_length=10, choices=((‘male‘, u‘男‘), (‘female‘, u‘女‘)), default=‘female‘, verbose_name=u‘性别‘) mobile = models.CharField(max_length=11, verbose_name=u‘电话‘) email = models.CharField(max_length=100, null=True, blank=True, verbose_name=u‘邮箱‘) class Meta: verbose_name_plural = verbose_name = u‘用户‘ def __str__(self): return self.name 2.在settings.py文件里面添加:在 ALLOWED_HOSTS = [] 后面添加:
AUTH_USER_MODEL = ‘users.UserProfile‘
时间: 2024-10-14 09:54:42