Opened 7 years ago

Closed 5 years ago

Last modified 5 years ago

#28667 closed Cleanup/optimization (fixed)

Documentation for extending UserCreationForm doesn't work with UserAdmin

Reported by: Nathanael Gordon Owned by: Swatantra
Component: contrib.auth Version: 2.2
Severity: Normal Keywords: add_fieldsets UserAdmin UserCreationForm Custom Auth User Model
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

In the docs for customising the Auth User model it does not fully outline the link between the UserCreationForm and the UserAdmin - specifically the fact that the UserAdmin's add_fieldsets will be used rather than the fields attribute in the Meta for the custom UserCreationForm.

At the end of this section (https://docs.djangoproject.com/en/1.11/topics/auth/customizing/#custom-users-and-the-built-in-auth-forms) it specifies that one can simply override the fields in the Meta of one's UserCreationForm. However, as the UserAdmin uses a custom get_fieldsets method which uses its add_fieldsets attribute instead, overriding fields does nothing.

Change History (11)

comment:1 by Tim Graham, 7 years ago

Summary: Lack of clear documentation for custom UserCreationForm when using a custom User modelDocumentation for extending UserCreationForm doesn't work with UserAdmin
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

comment:2 by Hampus Dunström, 6 years ago

Owner: changed from nobody to Hampus Dunström
Status: newassigned

comment:3 by Hampus Dunström, 6 years ago

I plan to be done with this at the end of October.

comment:4 by Hampus Dunström, 6 years ago

I'm having a hard time creating a test app with a UserCreationForm for a model based on the django.contrib.auth.admin.UserAdmin class. Is this not the class. Is there any example code anyone can show me?

At the end of this section (​https://docs.djangoproject.com/en/1.11/topics/auth/customizing/#custom-users-and-the-built-in-auth-forms) it specifies that one can simply override the fields in the Meta of one's UserCreationForm.

Above this example it is stated that it only works if the model is a simple subclass of AbstractUser. Do we want another example for UserAdmin or what are we looking for? Maybe I'm not the right person for this issue, I don't know. If any of you guys know anything or can clarify please let me know.

comment:5 by Hampus Dunström, 6 years ago

Owner: Hampus Dunström removed
Status: assignednew

comment:6 by eadhina, 6 years ago

Owner: set to eadhina
Status: newassigned

comment:7 by Carlton Gibson, 6 years ago

Owner: eadhina removed
Status: assignednew

Given the lack of updates I'm going to de-assign this issue so someone else looking can pick it up.

comment:8 by Swatantra, 5 years ago

Owner: set to Swatantra
Status: newassigned

comment:9 by Mariusz Felisiak, 5 years ago

Has patch: set
Version: 1.112.2

comment:10 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In c13e3715:

Fixed #28667 -- Clarified how to override list of forms fields for custom UserAdmin with a custom user model.

comment:11 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In 7d52d056:

[2.2.x] Fixed #28667 -- Clarified how to override list of forms fields for custom UserAdmin with a custom user model.

Backport of c13e3715f5f46f2ee4ddba357e2589a45e831813 from master

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