diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index 01f53aa..4e6c5ac 100644
a
|
b
|
class ReverseManyRelatedObjectsDescriptor(object):
|
558 | 558 | model=rel_model, |
559 | 559 | core_filters={'%s__pk' % self.field.related_query_name(): instance._get_pk_val()}, |
560 | 560 | instance=instance, |
561 | | symmetrical=(self.field.rel.symmetrical and instance.__class__ == rel_model), |
| 561 | symmetrical=(self.field.rel.symmetrical and isinstance(instance, rel_model)), |
562 | 562 | join_table=qn(self.field.m2m_db_table()), |
563 | 563 | source_col_name=qn(self.field.m2m_column_name()), |
564 | 564 | target_col_name=qn(self.field.m2m_reverse_name()) |
diff --git a/tests/regressiontests/m2m_regress/models.py b/tests/regressiontests/m2m_regress/models.py
index cffc137..5484b26 100644
a
|
b
|
class Entry(models.Model):
|
26 | 26 | def __unicode__(self): |
27 | 27 | return self.name |
28 | 28 | |
| 29 | # Two models both inheriting from a base model with a self-referential m2m field |
| 30 | class SelfReferChild(SelfRefer): |
| 31 | pass |
| 32 | |
| 33 | class SelfReferChildSibling(SelfRefer): |
| 34 | pass |
| 35 | |
29 | 36 | __test__ = {"regressions": """ |
30 | 37 | # Multiple m2m references to the same model or a different model must be |
31 | 38 | # distinguished when accessing the relations through an instance attribute. |
… |
… |
__test__ = {"regressions": """
|
57 | 64 | >>> SelfRefer.objects.filter(porcupine='fred') |
58 | 65 | Traceback (most recent call last): |
59 | 66 | ... |
60 | | FieldError: Cannot resolve keyword 'porcupine' into field. Choices are: id, name, references, related |
| 67 | FieldError: Cannot resolve keyword 'porcupine' into field. Choices are: id, name, references, related, selfreferchild, selfreferchildsibling |
| 68 | |
| 69 | # Test to ensure that the relationship between two inherited models |
| 70 | # with a self-referential m2m field maintains symmetry |
| 71 | >>> sr_child = SelfReferChild(name="Hanna") |
| 72 | >>> sr_child.save() |
| 73 | |
| 74 | >>> sr_sibling = SelfReferChildSibling(name="Beth") |
| 75 | >>> sr_sibling.save() |
| 76 | >>> sr_child.related.add(sr_sibling) |
| 77 | >>> sr_child.related.all() |
| 78 | [<SelfRefer: Beth>] |
| 79 | >>> sr_sibling.related.all() |
| 80 | [<SelfRefer: Hanna>] |
61 | 81 | |
62 | 82 | """ |
63 | 83 | } |