Opened 6 years ago
Closed 6 years ago
#29753 closed Bug (duplicate)
User Admin models use `django.contrib.auth.models.User` instead of `User = get_user_model()`
Reported by: | Ariel Pontes | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 2.1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I have a custom User model that is exactly the same as Django's default User model except for the fact that we allow longer usernames (I'm on Django 1.9, which has a 30 character limit on usernames). Because this is the only difference, I use all default User models in the Admin. However, when I try to create a user with a long username, I get the 30 character limit error. In the shell everything works fine. When investigating I saw that in the django/contrib/auth/forms.py
file, the UserCreationForm
referred to django.contrib.auth.models.User
. I believe it should refer instead to UserModel
(which is declared in the file using get_user_model()
).
Relevant lines:
Duplicate of #28608.