Solution:
forms.py
------------------------------------------------------------
from django import forms
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from django.utils.translation import ugettext as _
# 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.UserCreationForm 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."))
------------------------------------------------------------
admin.py
------------------------------------------------------------
class UserProfileAdmin(UserAdmin):
form = UserChangeForm
add_form = UserCreationForm
admin.site.unregister(User)
admin.site.register(User, UserProfileAdmin)
------------------------------------------------------------
On Aug 29, 11:52 am, Léon Dignòn <[email protected]> wrote:
> Hello,
>
> I don't find a way to allow additional characters in the username: -'[]
> {}[]…
>
> Sure, I could override the user model, but then my 3rd-party-
> application won't work anymore. (django-profiles/registration).
>
> Any ideas?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---