Opened 7 years ago
Closed 7 years ago
#29780 closed Cleanup/optimization (duplicate)
Using default UserModel in django.contrib.auth forms
| Reported by: | Marcelo Canina | Owned by: | |
|---|---|---|---|
| Component: | contrib.auth | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | yes | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
In django.contrib.auth.forms.py we have the
UserModel = get_user_model()
but User model is used twice in: UserCreationForm and UserChangeForm in theirs meta
class UserChangeForm(forms.ModelForm):
class Meta:
model = User
I think above forms should use UserModel instead of User so there is no need to subclass them to use project's user model when using a custom User model.
Change History (6)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Looks like the tests all passed. I have an issue with it though, how to really test this? By the time the tests run the UserChangeForm has already been executed and the metaclass already did its thing so no matter how much you change the AUTH_USER_MODEL nothing will change; I thought about making get_user_model() lazy.. but that could introduce further complications. I suppose thats why this was like this to begin with. Can anyone shed some light?
comment:3 by , 7 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:4 by , 7 years ago
| Owner: | removed |
|---|---|
| Status: | assigned → new |
comment:5 by , 7 years ago
| Needs tests: | set |
|---|---|
| Version: | 2.1 → master |
comment:6 by , 7 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
Duplicate of #28757. As you'll read about there, the issue isn't so simple.
Created this PR really quickly to see if it passes all tests on the first go. https://github.com/django/django/pull/10424