Commit 0831a43c authored by Gabriel Muñumel's avatar Gabriel Muñumel Committed by Tim Graham
Browse files

[1.7.x] Fixed #24352 -- Fixed crash when coercing ``ManyRelatedManager`` to a string.

parent aa6853da
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -855,6 +855,9 @@ def create_many_related_manager(superclass, rel):
            )
        do_not_call_in_templates = True

        def __str__(self):
            return repr(self)

        def _build_remove_filters(self, removed_vals):
            filters = Q(**{self.source_field_name: self.related_val})
            # No need to add a subquery condition if removed_vals is a QuerySet without
+2 −1
Original line number Diff line number Diff line
@@ -9,4 +9,5 @@ Django 1.7.6 fixes several bugs in 1.7.5.
Bugfixes
========

* ...
* Fixed crash when coercing ``ManyRelatedManager`` to a string
  (:ticket:`24352`).
+4 −0
Original line number Diff line number Diff line
@@ -109,3 +109,7 @@ class M2MRegressionTests(TestCase):
        worksheet.lines = hi
        self.assertEqual(1, worksheet.lines.count())
        self.assertEqual(1, hi.count())

    def test_many_related_manager_str(self):
        worksheet = Worksheet.objects.create(id=1)
        self.assertIn('ManyRelatedManager', str(worksheet.lines))