Hello. I'm trying to modify the Auth admin interface to work properly
with a custom Active Directory backend I've written. Basically, all I
want to do is change the username validation and remove the password
field from the display, leaving everything else as it is. The username
validation works exactly as I'd intended, allowing dashes in usernames
now, however it still shows me the password field. It's like the Meta
subclass of MyUserChangeForm is being ignored.

This is the code in my admin.py file:

-----------------------------------------------------------------------------------------------------------------------------------
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserChangeForm
from django.contrib.auth.admin import UserAdmin
from django.contrib import admin
from django import forms
from django.utils.translation import ugettext, ugettext_lazy as _

class MyUserChangeForm(UserChangeForm):
  username = forms.RegexField(label=_("Username"), max_length=30,
regex=r'^[\w-]+$',
    help_text = _("Required. 30 characters or fewer. Alphanumeric
characters only (letters, digits, dashes and underscores)."),
    error_message = _("This value must contain only letters, numbers,
dashes and underscores."))

  class Meta:
    exclude = ('password',)

class MyUserAdmin(UserAdmin):
  form = MyUserChangeForm

admin.site.unregister(User)
admin.site.unregister(Group)
admin.site.register(User, MyUserAdmin)
-----------------------------------------------------------------------------------------------------------------------------------

Have I missed something here?

Cheers,
Matt
--~--~---------~--~----~------------~-------~--~----~
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