Opened 3 years ago

Closed 3 years ago

#20188 closed Bug (invalid)

[contrib.auth.admin] We need to use the AUTH_USER_MODEL defined in the settings form admin form

Reported by: anonymous Owned by: nobody
Component: contrib.auth Version: 1.5
Severity: Normal Keywords:
Cc: bmispelon@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

As you can see here : https://github.com/django/django/blob/master/django/contrib/auth/forms.py#L89

We are using django.contrib.auth.models.User so it doesn't work when we register our Django custom User model with UserAdmin.

We should load the User from the settings.AUTH_USER_MODEL.

How to reproduce ?

Register your custom user with UserAdmin and try to add a user from the admin.

You will get an error because of this: https://github.com/django/django/blob/master/django/contrib/auth/forms.py#L97

Change History (2)

comment:1 Changed 3 years ago by remy.hubscher@…

Component: Uncategorizedcontrib.auth
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Type: UncategorizedBug

comment:2 Changed 3 years ago by Baptiste Mispelon

Cc: bmispelon@… added
Resolution: invalid
Status: newclosed

This is actually a documented behavior: https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#custom-users-and-the-built-in-auth-forms

The UserCreationForm "must be re-written for any custom user model".

I'm therefore closing this as invalid but note that there is some discussion on ticket #19353 that relates to this issue.

Thanks.

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