I have created a custom user model which I am successfully using within my app.
The problem is that within the Admin, on the user edit screen, I get a display of the present password hash, instead of the very useful interface for setting the password.
I am using Django 1.5b1 on Python 2.7.
How can I convince the Django admin to treat my user model the same way it treats the native User, for the sake of the admin user interface?
Documentation suggest that you need to register the custom model with admin and also define few methods as well so that admin interface works with custom user model.
You may also have to define built-in forms for User.
From Custom users and django.contrib.admin
You will also need to register your custom User model with the admin. If your custom User model extends AbstractUser, you can use Django's existing UserAdmin class. However, if your User model extends AbstractBaseUser, you'll need to define a custom ModelAdmin class.
Just add this to your form:
password = ReadOnlyPasswordHashField(
label= ("Password"),
help_text= ("Raw passwords are not stored, so there is no way to see "
"this user's password, but you can change the password "
"using <a href=\"password/\">this form</a>."))
Borrowed from https://stackoverflow.com/a/15630360/780262
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With