Follow me

Django 源码的学习(一)
十一月 21, 2013|Whistler

Django 源码的学习(一)


在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.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 ‘


    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


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


    class Meta:

        swappable = ‘AUTH_USER_MODEL’


no comments