#36291: ManyToManyField empty when setting related_name and related_query_name to "+" -------------------------------------+------------------------------------- Reporter: Hayder Mustafa | Owner: (none) Type: Bug | Status: closed Component: Database layer | Version: 5.2 (models, ORM) | Resolution: Severity: Normal | worksforme Keywords: | Triage Stage: | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by Sarah Boyce):
* resolution: => worksforme * status: new => closed Comment: I cannot replicate, can you try to write a regression test? This was what I have tested: {{{#!diff --- a/tests/m2m_regress/tests.py +++ b/tests/m2m_regress/tests.py @@ -11,6 +11,7 @@ from .models import ( SelfReferChildSibling, Tag, TagCollection, + Test, Worksheet, ) @@ -141,3 +142,13 @@ class M2MRegressionTests(TestCase): post.secondary_lines.add(bar) self.assertSequenceEqual(post.primary_lines.all(), [foo]) self.assertSequenceEqual(post.secondary_lines.all(), [bar]) + + def test_related_name_and_related_query_name_plus(self): + instance = Test.objects.create() + foo = Line.objects.create(name="foo") + bar = Line.objects.create(name="bar") + instance.lines.add(foo) + instance.lines.add(bar) + self.assertSequenceEqual(instance.lines.all(), [foo, bar]) + instance.refresh_from_db() + self.assertSequenceEqual(instance.lines.all(), [foo, bar]) }}} -- Ticket URL: <https://code.djangoproject.com/ticket/36291#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/django-updates/01070195fa890efb-d183829d-f6cd-4270-82b5-22ebda14292c-000000%40eu-central-1.amazonses.com.