diff --git a/django/contrib/auth/checks.py b/django/contrib/auth/checks.py index ec55c29665..853a675f88 100644 --- a/django/contrib/auth/checks.py +++ b/django/contrib/auth/checks.py @@ -15,7 +15,7 @@ def check_user_model(**kwargs): if not isinstance(cls.REQUIRED_FIELDS, (list, tuple)): errors.append( checks.Error( - 'The REQUIRED_FIELDS must be a list or tuple.', + "'REQUIRED_FIELDS' must be a list or tuple.", hint=None, obj=cls, id='auth.E001', @@ -26,9 +26,8 @@ def check_user_model(**kwargs): if cls.USERNAME_FIELD in cls.REQUIRED_FIELDS: errors.append( checks.Error( - ('The field named as the USERNAME_FIELD ' - 'must not be included in REQUIRED_FIELDS ' - 'on a custom user model.'), + ("The field named as the 'USERNAME_FIELD' " + "for a custom user model must not be included in 'REQUIRED_FIELDS'."), hint=None, obj=cls, id='auth.E002', @@ -41,8 +40,7 @@ def check_user_model(**kwargs): ('django.contrib.auth.backends.ModelBackend',)): errors.append( checks.Error( - ('The %s.%s field must be unique because it is ' - 'pointed to by USERNAME_FIELD.') % ( + "'%s.%s' must be unique because it is named as the 'USERNAME_FIELD'." % ( cls._meta.object_name, cls.USERNAME_FIELD ), hint=None, @@ -53,11 +51,10 @@ def check_user_model(**kwargs): else: errors.append( checks.Warning( - ('The %s.%s field is pointed to by USERNAME_FIELD, ' - 'but it is not unique.') % ( + "'%s.%s' is named as the 'USERNAME_FIELD', but it is not unique." % ( cls._meta.object_name, cls.USERNAME_FIELD ), - hint=('Ensure that your authentication backend can handle ' + hint=('Ensure that your authentication backend(s) can handle ' 'non-unique usernames.'), obj=cls, id='auth.W004', diff --git a/django/contrib/auth/tests/test_management.py b/django/contrib/auth/tests/test_management.py index 96d9571456..f0dc66baa3 100644 --- a/django/contrib/auth/tests/test_management.py +++ b/django/contrib/auth/tests/test_management.py @@ -358,7 +358,7 @@ class CustomUserModelValidationTestCase(TestCase): errors = checks.run_checks() expected = [ checks.Error( - 'The REQUIRED_FIELDS must be a list or tuple.', + "'REQUIRED_FIELDS' must be a list or tuple.", hint=None, obj=CustomUserNonListRequiredFields, id='auth.E001', @@ -375,8 +375,8 @@ class CustomUserModelValidationTestCase(TestCase): errors = checks.run_checks() expected = [ checks.Error( - ('The field named as the USERNAME_FIELD must not be included ' - 'in REQUIRED_FIELDS on a custom user model.'), + ("The field named as the 'USERNAME_FIELD' for a custom user model " + "must not be included in 'REQUIRED_FIELDS'."), hint=None, obj=CustomUserBadRequiredFields, id='auth.E002', @@ -393,8 +393,8 @@ class CustomUserModelValidationTestCase(TestCase): errors = checks.run_checks() expected = [ checks.Error( - ('The CustomUserNonUniqueUsername.username field must be ' - 'unique because it is pointed to by USERNAME_FIELD.'), + ("'CustomUserNonUniqueUsername.username' must be " + "unique because it is named as the 'USERNAME_FIELD'."), hint=None, obj=CustomUserNonUniqueUsername, id='auth.E003', @@ -416,9 +416,9 @@ class CustomUserModelValidationTestCase(TestCase): errors = checks.run_checks() expected = [ checks.Warning( - ('The CustomUserNonUniqueUsername.username field is pointed to ' - 'by USERNAME_FIELD, but it is not unique.'), - hint=('Ensure that your authentication backend can handle ' + ("'CustomUserNonUniqueUsername.username' is named as " + "the 'USERNAME_FIELD', but it is not unique."), + hint=('Ensure that your authentication backend(s) can handle ' 'non-unique usernames.'), obj=CustomUserNonUniqueUsername, id='auth.W004',