diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2009-04-13 02:59:40 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2009-04-13 02:59:40 +0000 |
| commit | 0fec0a5d704d487755209115719ca173913a43b7 (patch) | |
| tree | 9c7194d1857cfa26e0ee195f03132abcea4f844e /tests/regressiontests | |
| parent | ffd7b177c9eea9cfe131bc20a98448345436d67e (diff) | |
Fixed #10237 -- Corrected the handling of self-referential m2m fields when using multi-table inheritance. Thanks to Justin Lilly for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10550 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
| -rw-r--r-- | tests/regressiontests/m2m_regress/models.py | 22 |
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>] """ } |
