Ticket #5786: overrides.py

File overrides.py, 1.5 KB (added by leond, 10 years ago)
Line 
1################
2### forms.py ###
3################
4
5from django.contrib.auth.forms import UserCreationForm, UserChangeForm
6
7# Overrides django.contrib.auth.forms.UserCreationForm and changes
8# username to accept a wider range of character in the username.
9class UserCreationForm(UserCreationForm):
10    username = forms.RegexField(label=_("Username"), max_length=30, regex=r"^[\w'\.\-]+\s?[\w'\.\-]+$",
11        help_text = _("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."),
12        error_message = _("This value must contain only letters, numbers and underscores."))
13
14# Overrides django.contrib.auth.forms.UserChangeForm and changes
15# username to accept a wider range of character in the username.
16class UserChangeForm(UserChangeForm):
17    username = forms.RegexField(label=_("Username"), max_length=30, regex=r"^[\w'\.\-]+\s?[\w'\.\-]+$",
18        help_text = _("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."),
19        error_message = _("This value must contain only letters, numbers and underscores."))
20       
21       
22################
23### admin.py ###
24################
25       
26from stormskins.skins.forms import UserCreationForm, UserChangeForm       
27class UserProfileAdmin(UserAdmin):
28    inlines = [UserProfileInline]
29    form = UserChangeForm
30    add_form = UserCreationForm
31
32admin.site.unregister(User) 
33admin.site.register(User, UserProfileAdmin)
Back to Top