Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#19460 closed Uncategorized (invalid)

“Unknown password hashing algorithm” when logging in with custom model inheriting from django.contrib.auth.models.User

Reported by: anonymous Owned by: nobody
Component: Uncategorized Version: 1.4
Severity: Normal Keywords: user
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I created a custom user model by inheriting from django.contrib.auth.models.User, and added it to my admin. When I create an instance from MyUser admin, I have two (related) problems:

1- in the admin, the plain password (not uncrypted) is shown in the password field

2- when I try to login in my admin with an instance of MyUser, I get

Unknown password hashing algorithm '<mypassword>'. Did you specify it in the PASSWORD_HASHERS setting


is it a bug? how can I fix that? (I'm using Django 1.4.2)

models.py

from django.contrib.auth.models import User

class MyUser(User):
    number = models.IntegerField()

admin.py

class MyUserAdmin(admin.ModelAdmin):
    fields = ('username', 'password', 'number', 'first_name', 'last_name')

admin.site.register(MyUser, MyUserAdmin)

Change History (2)

comment:1 by Russell Keith-Magee, 12 years ago

Resolution: invalid
Status: newclosed

No, this isn't a bug. Your admin class is doing exactly what you've asked it to do, which is to display the default behaviour. If you dig into Django's code, you'll see that there's a lot of special handling in place to make the User class handle hashed passwords.

If you want a custom user class, this isn't how you do it. In Django 1.5, we're adding support for custom Users, which is documented; in Django 1.4, you can define user profiles, but not custom User classes. If you want more details, your question should be directed at the django-users mailing list.

comment:2 by anonymous, 12 years ago

Buuuu, i need it, then i wil create another backend authenticator

Note: See TracTickets for help on using tickets.
Back to Top