summaryrefslogtreecommitdiff
path: root/tests/generic_relations_regress
diff options
context:
space:
mode:
authorrobwa <robwa@users.noreply.github.com>2018-03-13 03:42:48 +0100
committerTim Graham <timograham@gmail.com>2018-03-12 22:42:48 -0400
commit4ab027b94409e6415b774797bf9d3593da9d9ea8 (patch)
tree03c9c8d5c2906658877cbb848c013a9bb1036cc7 /tests/generic_relations_regress
parentb639bcc2503d66870f72bdffc01abc015a548462 (diff)
downloaddjango-4ab027b94409e6415b774797bf9d3593da9d9ea8.tar.gz
Fixed #28988 -- Fixed queries when a GenericRelation is used with multi-table inheritance.
Diffstat (limited to 'tests/generic_relations_regress')
-rw-r--r--tests/generic_relations_regress/models.py2
-rw-r--r--tests/generic_relations_regress/tests.py10
2 files changed, 11 insertions, 1 deletions
diff --git a/tests/generic_relations_regress/models.py b/tests/generic_relations_regress/models.py
index c9572eb961..5d8716aa0c 100644
--- a/tests/generic_relations_regress/models.py
+++ b/tests/generic_relations_regress/models.py
@@ -26,7 +26,7 @@ class LinkProxy(Link):
class Place(models.Model):
name = models.CharField(max_length=100)
- links = GenericRelation(Link)
+ links = GenericRelation(Link, related_query_name='places')
link_proxy = GenericRelation(LinkProxy)
def __str__(self):
diff --git a/tests/generic_relations_regress/tests.py b/tests/generic_relations_regress/tests.py
index 91158d8198..769a64d0f1 100644
--- a/tests/generic_relations_regress/tests.py
+++ b/tests/generic_relations_regress/tests.py
@@ -263,3 +263,13 @@ class GenericRelationTests(TestCase):
place = Place.objects.create()
Link.objects.create(content_object=place)
self.assertEqual(Place.objects.get(link_proxy__object_id=place.id), place)
+
+ def test_generic_reverse_relation_with_mti(self):
+ """
+ Filtering with a reverse generic relation, where the GenericRelation
+ comes from multi-table inheritance.
+ """
+ place = Place.objects.create(name='Test Place')
+ link = Link.objects.create(content_object=place)
+ result = Link.objects.filter(places=place)
+ self.assertCountEqual(result, [link])