Hi,

i want to know what the best practice is for following problem.
I use the built in user authentication framework. I've already made the login
authenticate against our AD. Works fine (see 
http://www.djangosnippets.org/snippets/901/)

In our company, usernames are specified with a period between the first
and last name. When i want to edit or add a user with the admin view,
i get a warning.
To change this behaviour, i edited UserCreationForm and UserChangeForm from 
django\contrib\auth\forms.py.
This doesn't feel right as changes will be lost when i update django (i track 
svn so it happens :))
so how would i go about to change this in a decent way?

I tried to override the 2 forms in my models.py file

class MyUserCreationForm(UserCreationForm):
    username = forms.RegexField(label=_("Username"), max_length=30, 
regex=r'[EMAIL PROTECTED]',
        help_text = _("Required. 30 characters or fewer. Alphanumeric 
characters only (letters, digits, underscores,            
        period, @ and +)."),
        error_message = _("This value must contain only letters, numbers and 
underscores."))
    class Meta:
        model = User
        fields = ("username",)

class MyUserChangeForm(UserChangeForm):
    username = forms.RegexField(label=_("Username"), max_length=30, 
regex=r'[EMAIL PROTECTED]',
        help_text = _("Required. 30 characters or fewer. Alphanumeric 
characters only (letters, digits, underscores,
        period, @ and +)."),
        error_message = _("This value must contain only letters, numbers and 
underscores."))
    class Meta:
        model = User

Then in my admin.py file:
class MyUserAdmin(admin.ModelAdmin):
    form = MyUserChangeForm
    add_form = MyUserCreationForm
admin.site.register(User, MyUserAdmin)

But then i get the error message "The model User is already registered"
I had the same error when i wanted to change the permissions
on the default User.

Thanks,
Benedict


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to