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

This commit is contained in:
aryan 2020-02-20 23:46:59 +05:30 committed by Mariusz Felisiak
parent 5637933268
commit fba5d3b6e6
2 changed files with 9 additions and 0 deletions

View File

@ -41,6 +41,11 @@ def check_user_model(app_configs=None, **kwargs):
checks.Error(
"The field named as the 'USERNAME_FIELD' "
"for a custom user model must not be included in 'REQUIRED_FIELDS'.",
hint=(
"The 'USERNAME_FIELD' is currently set to '%s', you "
"should remove '%s' from the 'REQUIRED_FIELDS'."
% (cls.USERNAME_FIELD, cls.USERNAME_FIELD)
),
obj=cls,
id='auth.E002',
)

View File

@ -49,6 +49,10 @@ class UserModelChecksTests(SimpleTestCase):
checks.Error(
"The field named as the 'USERNAME_FIELD' for a custom user model "
"must not be included in 'REQUIRED_FIELDS'.",
hint=(
"The 'USERNAME_FIELD' is currently set to 'username', you "
"should remove 'username' from the 'REQUIRED_FIELDS'."
),
obj=CustomUserBadRequiredFields,
id='auth.E002',
),