Opened 5 years ago

Closed 5 years ago

#31289 closed Cleanup/optimization (fixed)

system checks: admin.E002 could provide a hint but doesn't

Reported by: Keryn Knight Owned by: Sanskar Jaiswal
Component: Core (System checks) Version: 3.0
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Currently the output is:

myapp.MyCustomUserModel: (auth.E002) The field named as the 'USERNAME_FIELD' for a custom user model must not be included in 'REQUIRED_FIELDS'.

because I accidentally had:

USERNAME_FIELD = "email"
EMAIL_FIELD = "email"
REQUIRED_FIELDS = (USERNAME_FIELD, "full_name",)

Ignoring the fact that Django knows it's wrong to have it in there, and could easily just skip it or warn if it's not set, it doesn't make use of the hints available in system checks.

I'd like to suggest that a hint could be provided which says which field it's moaning about, something like (open to better wording):

HINT: Your username field is currently set to "email", you should remove "email" from your required fields definition.

It's a stupidly little thing, but having not had to make a custom user from scratch for a while, my eyes glazed over the not in must not be and I was confused for all of 2 minutes before actually reading it properly.

Change History (5)

comment:1 by Carlton Gibson, 5 years ago

Triage Stage: UnreviewedAccepted
Type: New featureCleanup/optimization

OK, fair enough. Got bandwidth for a patch?

comment:2 by Sanskar Jaiswal, 5 years ago

Owner: changed from nobody to Sanskar Jaiswal
Status: newassigned

comment:3 by Carlton Gibson, 5 years ago

Patch needs improvement: set

comment:4 by Mariusz Felisiak, 5 years ago

Has patch: set
Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:5 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In fba5d3b6:

Fixed #31289 -- Added hint for USERNAME_FIELD/REQUIRED_FIELDS system check.

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