Opened 13 years ago
Closed 13 years ago
#20097 closed Cleanup/optimization (invalid)
The field named as the USERNAME_FIELD should not be included in REQUIRED_FIELDS on a swappable User model.
| Reported by: | Alper Cugun | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.auth | Version: | 1.5 |
| Severity: | Normal | Keywords: | |
| Cc: | bmispelon@… | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I've created a User model that subclasses AbstractBaseUser and contains just this:
USERNAME_FIELD = 'email'
If I try to use that django gives this error:
"The field named as the USERNAME_FIELD should not be included in REQUIRED_FIELDS on a swappable User model."
Which I can't figure out because I haven't put anything in REQUIRED_FIELDS.
Note:
See TracTickets
for help on using tickets.
Hi,
AbstractBaseUser does not have anemail` field so the following is invalid:This will raise the following error:
MyCustomUser has no field named 'email'Now, if you subclass
AbstractUserinstead in the same fashion, then you get the error message you indicated.The reason for this is that
AbstractUserdefinesREQUIRED_FIELDS = ['email'], hence the error message.