diff --git a/django/contrib/contenttypes/fields.py b/django/contrib/contenttypes/fields.py index 7c27d5960b..b70a947ddf 100644 --- a/django/contrib/contenttypes/fields.py +++ b/django/contrib/contenttypes/fields.py @@ -453,6 +453,9 @@ def create_generic_related_manager(superclass): ) do_not_call_in_templates = True + def __str__(self): + return repr(self) + def get_queryset(self): try: return self.instance._prefetched_objects_cache[self.prefetch_cache_name] diff --git a/tests/generic_relations_regress/tests.py b/tests/generic_relations_regress/tests.py index 93eac5292b..2804530f84 100644 --- a/tests/generic_relations_regress/tests.py +++ b/tests/generic_relations_regress/tests.py @@ -260,3 +260,7 @@ class GenericRelationTests(TestCase): # where the pre_delete signal should fire and prevent deletion. with self.assertRaises(ProtectedError): related.delete() + + def test_ticket_22982(self): + place = Place.objects.create(name='My Place') + self.assertIn('GenericRelatedObjectManager', str(place.links))