Opened 9 years ago

Closed 9 years ago

#24087 closed Bug (duplicate)

django.contrib.forms.UserCreationForm inheritence won't work

Reported by: Matías Lang Owned by: nobody
Component: contrib.auth Version: 1.7
Severity: Normal Keywords: forms, auth, users, custom
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If I create a custom User model based on AbstractUser, i should also create a custom user creation form, inheriting from django.contrib.forms.UserCreationForm and defining the custom model I created in the Meta subclass. This won't work properly because UserCreationForm always use auth.User model when cleaning the username instead of the one defined in Meta.
This should be patched changing lines 101 and 102 of contrib/auth/forms.py, from this:
101 User._default_manager.get(username=username)
102 except User.DoesNotExist:
To this
101 self.Meta.model._default_manager.get(username=username)
102 except self.Meta.model.DoesNotExist:

Change History (1)

comment:1 by Tim Graham, 9 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #19353

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