diff --git a/django/contrib/contenttypes/models.py b/django/contrib/contenttypes/models.py index 759a53ce67..0d98ed3a4d 100644 --- a/django/contrib/contenttypes/models.py +++ b/django/contrib/contenttypes/models.py @@ -162,7 +162,10 @@ class ContentType(models.Model): model = self.model_class() if not model: return self.model - return "%s | %s" % (model._meta.app_label, model._meta.verbose_name) + return "%s | %s" % ( + model._meta.app_config.verbose_name, + model._meta.verbose_name, + ) def model_class(self): """Return the model class for this type of content.""" diff --git a/tests/auth_tests/test_models.py b/tests/auth_tests/test_models.py index fe1afcbdc3..41f822fdc7 100644 --- a/tests/auth_tests/test_models.py +++ b/tests/auth_tests/test_models.py @@ -587,5 +587,5 @@ class PermissionTests(TestCase): def test_str(self): p = Permission.objects.get(codename="view_customemailfield") self.assertEqual( - str(p), "auth_tests | custom email field | Can view custom email field" + str(p), "Auth_Tests | custom email field | Can view custom email field" ) diff --git a/tests/contenttypes_tests/test_models.py b/tests/contenttypes_tests/test_models.py index 2b346b0e44..95518bb3df 100644 --- a/tests/contenttypes_tests/test_models.py +++ b/tests/contenttypes_tests/test_models.py @@ -280,7 +280,11 @@ class ContentTypesTests(TestCase): def test_str(self): ct = ContentType.objects.get(app_label="contenttypes_tests", model="site") - self.assertEqual(str(ct), "contenttypes_tests | site") + self.assertEqual(str(ct), "Contenttypes_Tests | site") + + def test_str_auth(self): + ct = ContentType.objects.get(app_label="auth", model="group") + self.assertEqual(str(ct), "Authentication and Authorization | group") def test_name(self): ct = ContentType.objects.get(app_label="contenttypes_tests", model="site") @@ -288,7 +292,7 @@ class ContentTypesTests(TestCase): def test_app_labeled_name(self): ct = ContentType.objects.get(app_label="contenttypes_tests", model="site") - self.assertEqual(ct.app_labeled_name, "contenttypes_tests | site") + self.assertEqual(ct.app_labeled_name, "Contenttypes_Tests | site") def test_name_unknown_model(self): ct = ContentType(app_label="contenttypes_tests", model="unknown") diff --git a/tests/i18n/contenttypes/tests.py b/tests/i18n/contenttypes/tests.py index 22bbb5d834..10e6c5ed69 100644 --- a/tests/i18n/contenttypes/tests.py +++ b/tests/i18n/contenttypes/tests.py @@ -20,6 +20,6 @@ class ContentTypeTests(TestCase): def test_verbose_name(self): company_type = ContentType.objects.get(app_label="i18n", model="company") with translation.override("en"): - self.assertEqual(str(company_type), "i18n | Company") + self.assertEqual(str(company_type), "I18N | Company") with translation.override("fr"): - self.assertEqual(str(company_type), "i18n | Société") + self.assertEqual(str(company_type), "I18N | Société") diff --git a/tests/multiple_database/tests.py b/tests/multiple_database/tests.py index bdbe641cdf..337ebae75e 100644 --- a/tests/multiple_database/tests.py +++ b/tests/multiple_database/tests.py @@ -1118,7 +1118,7 @@ class QueryTestCase(TestCase): # Set a foreign key with an object from a different database msg = ( - 'Cannot assign "": the ' + 'Cannot assign "": the ' "current database router prevents this relation." ) with self.assertRaisesMessage(ValueError, msg):