diff options
| author | Jacob Haslehurst <jacob@haslehurst.net> | 2014-08-07 16:06:44 +1000 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-08-07 14:44:20 -0400 |
| commit | f676305ecede116332884ea682fc953c29813232 (patch) | |
| tree | 3e49c55b5dfad015410bf7b57d4b80178f28098c | |
| parent | f9f9f3ad6073c353af924ed90c9386efd7bde8ac (diff) | |
Fixed #22982 -- Added GenericRelatedObjectManager.__str__. to prevent crash.
Thanks bendavis78 for the report.
Forwardport of 29585e9b6a from stable/1.7.x
| -rw-r--r-- | django/contrib/contenttypes/fields.py | 3 | ||||
| -rw-r--r-- | tests/generic_relations_regress/tests.py | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/django/contrib/contenttypes/fields.py b/django/contrib/contenttypes/fields.py index 3c3b4d0039..5620d735fc 100644 --- a/django/contrib/contenttypes/fields.py +++ b/django/contrib/contenttypes/fields.py @@ -457,6 +457,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)) |
