Ticket #5786: 5786.django.contrib.auth.diff

File 5786.django.contrib.auth.diff, 3.3 KB (added by Pete Crosier, 12 years ago)

A more liberal approach to relaxing username restrictions

  • django/contrib/auth/tests.py

     
    3535[]
    3636>>> a.user_permissions.all()
    3737[]
    38 """
     38
     39>>> u3 = User.objects.create_user('testuser3@example.com', 'test3@example.com', 'test3')
     40>>> u3.username = 'testuser3a@example.com'
     41>>> u3.save()
     42"""
  • django/contrib/auth/models.py

     
    128128
    129129    Username and password are required. Other fields are optional.
    130130    """
    131     username = models.CharField(_('username'), max_length=30, unique=True, validator_list=[validators.isAlphaNumeric], help_text=_("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."))
     131    username = models.CharField(_('username'), max_length=30, unique=True, help_text=_("Required. 30 characters or fewer."))
    132132    first_name = models.CharField(_('first name'), max_length=30, blank=True)
    133133    last_name = models.CharField(_('last name'), max_length=30, blank=True)
    134134    email = models.EmailField(_('e-mail address'), blank=True)
  • django/contrib/auth/forms.py

     
    1111    def __init__(self):
    1212        self.fields = (
    1313            oldforms.TextField(field_name='username', length=30, max_length=30, is_required=True,
    14                 validator_list=[validators.isAlphaNumeric, self.isValidUsername]),
     14                validator_list=[self.isValidUsername]),
    1515            oldforms.PasswordField(field_name='password1', length=30, max_length=60, is_required=True),
    1616            oldforms.PasswordField(field_name='password2', length=30, max_length=60, is_required=True,
    1717                validator_list=[validators.AlwaysMatchesOtherField('password1', _("The two password fields didn't match."))]),
  • tests/regressiontests/auth_backends/tests.py

     
    6969True
    7070>>> user.has_perms(['auth.test3', 'auth.test_group'])
    7171True
     72
     73>>> user = User.objects.create_user('test2@example.com', 'test2@example.com', 'test')
     74>>> user = User.objects.get(username="test2@example.com")
     75>>> user.username
     76u'test2@example.com'
     77>>> user.username = 'test2a@example.com'
     78>>> user.save()
    7279"""}
  • docs/authentication.txt

     
    5656
    5757``User`` objects have the following fields:
    5858
    59     * ``username`` -- Required. 30 characters or fewer. Alphanumeric characters
    60       only (letters, digits and underscores).
     59    * ``username`` -- Required. 30 characters or fewer. May contain any
     60      character.
    6161    * ``first_name`` -- Optional. 30 characters or fewer.
    6262    * ``last_name`` -- Optional. 30 characters or fewer.
    6363    * ``email`` -- Optional. E-mail address.
Back to Top