#9541 closed (duplicate)
Allow wider choice of usernames
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.auth | Version: | |
Severity: | Keywords: | ||
Cc: | richard.davies@… | Triage Stage: | Unreviewed |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
django.contrib.auth restricts usernames to 30 characters or fewer, matching \w
Whilst it's good to disallow extreme values, this constraint can be significantly relaxed to allow longer usernames and some more characters (e.g. - . / \ )
My specific need is to allow UUIDs as usernames, so I attach a patch with extends to 36 characters and allows hyphens. I would encourage the maintainers to generalize this further before check in, to an even longer length and wider range of characters.
Attachments (1)
Change History (3)
by , 16 years ago
Attachment: | 9541-r9368-wider-choice-of-username.diff added |
---|
comment:1 by , 16 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:2 by , 15 years ago
As a note for anyone else with a similar problem: Instead of patching Django itself, you can alternatively monkey patch against a standard Django install. In my case, the equivalent monkey patch is as below, and I include this in my application's models.py
User._meta.get_field('username').max_length = 36 from django.contrib.auth.forms import UserCreationForm, UserChangeForm, AuthenticationForm UserCreationForm.declared_fields['username'].max_length = 36 UserCreationForm.declared_fields['username'].regex = re.compile(r'^[\w-]+$') UserChangeForm.declared_fields['username'].max_length = 36 UserChangeForm.declared_fields['username'].regex = re.compile(r'^[\w-]+$') AuthenticationForm.base_fields['username'].max_length = 36 #AuthenticationForm.base_fields['username'].max_length = re.compile(r'^[\w-]+$') -- if #11127 adopted
Duplicate of #8432, #7591, and #8878 (and probably others).