1 | ################
|
---|
2 | ### forms.py ###
|
---|
3 | ################
|
---|
4 |
|
---|
5 | from 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.
|
---|
9 | class 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.
|
---|
16 | class 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 |
|
---|
26 | from stormskins.skins.forms import UserCreationForm, UserChangeForm
|
---|
27 | class UserProfileAdmin(UserAdmin):
|
---|
28 | inlines = [UserProfileInline]
|
---|
29 | form = UserChangeForm
|
---|
30 | add_form = UserCreationForm
|
---|
31 |
|
---|
32 | admin.site.unregister(User)
|
---|
33 | admin.site.register(User, UserProfileAdmin)
|
---|