Ticket #8379: r8520-validate-username.patch
File r8520-validate-username.patch, 1.9 KB (added by , 16 years ago) |
---|
-
django/contrib/auth/admin.py
1 2 1 from django.contrib.auth.models import User, Group 3 2 from django.core.exceptions import PermissionDenied 4 3 from django import template … … 7 6 from django.utils.html import escape 8 7 from django.http import HttpResponseRedirect 9 8 from django.utils.translation import ugettext, ugettext_lazy as _ 10 from django.contrib.auth.forms import UserCreationForm, AdminPasswordChangeForm9 from django.contrib.auth.forms import UserCreationForm, UserChangeForm, AdminPasswordChangeForm 11 10 from django.contrib import admin 12 11 13 12 class GroupAdmin(admin.ModelAdmin): … … 23 22 (_('Important dates'), {'fields': ('last_login', 'date_joined')}), 24 23 (_('Groups'), {'fields': ('groups',)}), 25 24 ) 25 form = UserChangeForm 26 26 add_form = UserCreationForm 27 27 change_password_form = AdminPasswordChangeForm 28 28 list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff') -
django/contrib/auth/forms.py
43 43 user.save() 44 44 return user 45 45 46 class UserChangeForm(forms.ModelForm): 47 username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^\w+$', 48 help_text = _("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."), 49 error_message = _("This value must contain only letters, numbers and underscores.")) 50 51 class Meta: 52 model = User 53 46 54 class AuthenticationForm(forms.Form): 47 55 """ 48 56 Base class for authenticating users. Extend this to get a form that accepts