Reputation: 3820
In a Django 1.5 project, I've created a custom User model extending from AbstractBaseUser to make the email address the primary key (instead of a username).
How do I get the change password functionality for UserAdmin in the django admin interface? I tried extending UserAdmin with a class called CustomUserAdmin (much like the answer suggested in Using custom User admin breaks change password form in Django's admin), but I get the following error message
CustomUserAdmin.list_display[0], 'username' is not a callable or an attribute of 'CustomUserAdmin' or found in the model 'User'.
I basically want the default admin interface except the password field (which I want from UserAdmin).
How do I do this?
Upvotes: 2
Views: 975
Reputation: 4961
Looks like your custom User model doesn't have 'username' field. And since CustomUserAdmin is extending UserAdmin, which assumes 'username' field is present; we are getting this error.
I would suggest you add a 'username' field in your custom model and store the same value of 'email' field in it.
Or override all the attributes of UserAdmin class which uses 'username'. Eg:
class CustomUserAdmin(UserAdmin):
list_display = ['email', 'first_name'.....]
Upvotes: 0