Opened 2 months ago

Last modified 2 days ago

#28608 assigned Cleanup/optimization

Allow UserCreationForm and UserChangeForm to work with custom user models

Reported by: Rômulo Collopy Owned by: hui shang
Component: contrib.auth Version: master
Severity: Normal Keywords: user, custom user, auth
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


class UserChangeForm(forms.ModelForm):
    # ...
    class Meta:
        model = User


class UserCreationForm(forms.ModelForm):
    class Meta:
        model = User

could use UserModel instead of User. It is already defined in and is used in other forms of the same package.

This would allow Django Registration and other packages that use these forms to work out of the box. And it would allow using them with no need to rewitte as specified at

Attachments (1)

patch.diff (2.2 KB) - added by Rômulo Collopy 2 months ago.

Download all attachments as: .zip

Change History (4)

Changed 2 months ago by Rômulo Collopy

Attachment: patch.diff added


comment:1 Changed 8 weeks ago by Tim Graham

Patch needs improvement: set
Summary: UserCreationForm and UserChangeForm model using get_user_modelAllow UserCreationForm and UserChangeForm to work with custom user models

This is a continuation of #19353.

comment:2 Changed 8 weeks ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:3 Changed 2 days ago by hui shang

Owner: changed from nobody to hui shang
Patch needs improvement: unset
Status: newassigned

Since This ticket is related to ticket 28757, I made the changes for this ticket and ticket 28757 in the same commit.


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