It's easier than that, since the username field is a CharField!
Add these lines to your admin.py:
--------------
from django.contrib.auth.forms import UserCreationForm,
UserChangeForm
# Overrides django.contrib.auth.forms.UserCreationForm and changes
# username to accept a wider range of character in the username.
class UserCreationForm(UserCreationForm):
username = forms.RegexField(label=_("Username"), max_length=30,
regex=r"^[\w'\.\-]+\s?[\w'\.\-]+$",
help_text = _("Required. 30 characters or fewer. Alphanumeric
characters only (letters, digits and underscores)."),
error_message = _("This value must contain only letters,
numbers and underscores."))
# Overrides django.contrib.auth.forms.UserChangeForm and changes
# username to accept a wider range of character in the username.
class UserChangeForm(UserChangeForm):
username = forms.RegexField(label=_("Username"), max_length=30,
regex=r"^[\w'\.\-]+\s?[\w'\.\-]+$",
help_text = _("Required. 30 characters or fewer. Alphanumeric
characters only (letters, digits and underscores)."),
error_message = _("This value must contain only letters,
numbers and underscores."))
class UserProfileAdmin(UserAdmin):
form = UserChangeForm
add_form = UserCreationForm
admin.site.unregister(User)
admin.site.register(User, UserProfileAdmin)
--------------
-ld
On Sep 5, 1:29 pm, joymax <[email protected]> wrote:
> You have to create custom authentication backend (more about it
> herehttp://docs.djangoproject.com/en/dev/topics/auth/#writing-an-authenti...).
>
> On Sep 5, 12:42 pm, Казбек <[email protected]> wrote:
>
>
>
> > Good day. How can i make django to register and use unicode usernames?
> > When i try to register one (russian symbols username) i get an error
> > says that the username must not contain such symbols. I try to
> > register username in admin panel. Thanks.- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---