I went through django/contrib/auth/models.py to check the definition
of the User model. I don't see this file defining any restrictions on
what a username can be. So, I think the form is the place (and
possibly the only place) which defines and enforces restrictions on
what the username can be.
Interestingly, the help_text for User.username is the following:
help_text=_('Required. 30 characters or fewer. Letters,
numbers and '
'@/./+/-/_ characters'))
But this restriction in neither defined nor enforced in the User model
class.
> isn't it supposed to be automatic, coming from the restrictions of the model since it's a ModelForm?
I didn't understand this comment. Why would you think ModelForm has
anything to do with it? As in, why would ModelForm know anything about
User.username.
thanks,
-pavan