summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2009-04-13 03:07:59 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2009-04-13 03:07:59 +0000
commit2c6e3b30b3caaa3d3422843f0e16b0d0ae1f4b76 (patch)
tree6fd207eb90dcdf50413bd74b0e4485d20bb57f48 /tests
parentcab85015c59028c490f6cfd3e15f5f80e3f1055d (diff)
[1.0.X] Fixed #10237 -- Corrected the handling of self-referential m2m fields when using multi-table inheritance. Thanks to Justin Lilly for the report and patch.
Merge of r10550 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10551 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/m2m_regress/models.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/regressiontests/m2m_regress/models.py b/tests/regressiontests/m2m_regress/models.py
index cffc137e70..5484b26d17 100644
--- a/tests/regressiontests/m2m_regress/models.py
+++ b/tests/regressiontests/m2m_regress/models.py
@@ -26,6 +26,13 @@ class Entry(models.Model):
def __unicode__(self):
return self.name
+# Two models both inheriting from a base model with a self-referential m2m field
+class SelfReferChild(SelfRefer):
+ pass
+
+class SelfReferChildSibling(SelfRefer):
+ pass
+
__test__ = {"regressions": """
# Multiple m2m references to the same model or a different model must be
# distinguished when accessing the relations through an instance attribute.
@@ -57,7 +64,20 @@ __test__ = {"regressions": """
>>> SelfRefer.objects.filter(porcupine='fred')
Traceback (most recent call last):
...
-FieldError: Cannot resolve keyword 'porcupine' into field. Choices are: id, name, references, related
+FieldError: Cannot resolve keyword 'porcupine' into field. Choices are: id, name, references, related, selfreferchild, selfreferchildsibling
+
+# Test to ensure that the relationship between two inherited models
+# with a self-referential m2m field maintains symmetry
+>>> sr_child = SelfReferChild(name="Hanna")
+>>> sr_child.save()
+
+>>> sr_sibling = SelfReferChildSibling(name="Beth")
+>>> sr_sibling.save()
+>>> sr_child.related.add(sr_sibling)
+>>> sr_child.related.all()
+[<SelfRefer: Beth>]
+>>> sr_sibling.related.all()
+[<SelfRefer: Hanna>]
"""
}