Wiadomość napisana w dniu 2008-10-29, o godz. 16:39, przez Benedict  
Verheyen:

> 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.


You have to unregister the admin class for User model before  
registering your own.

-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda, R&D, Redefine
[EMAIL PROTECTED]


--~--~---------~--~----~------------~-------~--~----~
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