您的位置:首页 > 编程语言 > Go语言

Django 源码的学习(一)

2013-11-21 22:58 337 查看
今晚看了下auth/auth,看了下docs,发现红色部分应该是个失误吧,email不是required的,因为

在AbstractUser class中的email = models.EmailField(_('email address'), blank=True)blank=True可以看出

class AbstractUser(AbstractBaseUser, PermissionsMixin):

    """

    An abstract base class implementing a fully featured User model with

    admin-compliant permissions.

    Username, password and email are required. Other fields are optional.

    """

    username = models.CharField(_('username'), max_length=30, unique=True,

        help_text=_('Required. 30 characters or fewer. Letters, numbers and '

                    '@/./+/-/_ characters'),

        validators=[

            validators.RegexValidator(re.compile('^[\w.@+-]+$'), _('Enter a valid username.'), 'invalid')

        ])

    first_name = models.CharField(_('first name'), max_length=30, blank=True)

    last_name = models.CharField(_('last name'), max_length=30, blank=True)

    email = models.EmailField(_('email address'), blank=True)

    is_staff = models.BooleanField(_('staff status'), default=False,

        help_text=_('Designates whether the user can log into this admin '

                    'site.'))

    is_active = models.BooleanField(_('active'), default=True,

        help_text=_('Designates whether this user should be treated as '

                    'active. Unselect this instead of deleting accounts.'))

    date_joined = models.DateTimeField(_('date joined'), default=timezone.now)

    objects = UserManager()

class User(AbstractUser):

    """

    Users within the Django authentication system are represented by this

    model.

    Username, password and email are required. Other fields are optional.

    """

    class Meta:

        swappable = 'AUTH_USER_MODEL'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息