summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/contrib/contenttypes/models.py2
-rw-r--r--tests/contenttypes_tests/test_models.py6
2 files changed, 4 insertions, 4 deletions
diff --git a/django/contrib/contenttypes/models.py b/django/contrib/contenttypes/models.py
index 1ae45dea95..f634976a93 100644
--- a/django/contrib/contenttypes/models.py
+++ b/django/contrib/contenttypes/models.py
@@ -156,7 +156,7 @@ class ContentType(models.Model):
def app_labeled_name(self):
model = self.model_class()
if not model:
- return self.model
+ return "%s | %s" % (self.app_label, self.model)
return "%s | %s" % (
model._meta.app_config.verbose_name,
model._meta.verbose_name,
diff --git a/tests/contenttypes_tests/test_models.py b/tests/contenttypes_tests/test_models.py
index b63c57ef09..542f0c8fd8 100644
--- a/tests/contenttypes_tests/test_models.py
+++ b/tests/contenttypes_tests/test_models.py
@@ -145,7 +145,7 @@ class ContentTypesTests(TestCase):
ct = ContentType.objects.get_for_model(ModelCreatedOnTheFly)
self.assertEqual(ct.app_label, "contenttypes_tests")
self.assertEqual(ct.model, "modelcreatedonthefly")
- self.assertEqual(str(ct), "modelcreatedonthefly")
+ self.assertEqual(str(ct), "contenttypes_tests | modelcreatedonthefly")
def test_get_for_concrete_model(self):
"""
@@ -269,7 +269,7 @@ class ContentTypesTests(TestCase):
app_label="contenttypes",
model="OldModel",
)
- self.assertEqual(str(ct), "OldModel")
+ self.assertEqual(str(ct), "contenttypes | OldModel")
self.assertIsNone(ct.model_class())
# Stale ContentTypes can be fetched like any other object.
@@ -318,7 +318,7 @@ class ContentTypesTests(TestCase):
def test_app_labeled_name_unknown_model(self):
ct = ContentType(app_label="contenttypes_tests", model="unknown")
- self.assertEqual(ct.app_labeled_name, "unknown")
+ self.assertEqual(ct.app_labeled_name, "contenttypes_tests | unknown")
class TestRouter: