summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-04-02 15:52:58 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-04-02 15:52:58 +0000
commitac0aea8910ec72a874ccd859a4f6449a895f4ec0 (patch)
treed3990db233b0979d093b8e2ba54eabcf14a18452 /tests
parentadfeb962273a9c0f918a3078e1612c6ac95f3cd6 (diff)
[1.1.X] Fixed #11956 -- Modified the handling of m2m relationships between subclasses. Thanks to nidi for the report, and astoneman for the suggestion on how to fix the problem.
Backport of r12908 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12909 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/m2m_regress/models.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/regressiontests/m2m_regress/models.py b/tests/regressiontests/m2m_regress/models.py
index 7f6da3341b..5453d396ae 100644
--- a/tests/regressiontests/m2m_regress/models.py
+++ b/tests/regressiontests/m2m_regress/models.py
@@ -17,6 +17,13 @@ class Tag(models.Model):
def __unicode__(self):
return self.name
+# Regression for #11956 -- a many to many to the base class
+class TagCollection(Tag):
+ tags = models.ManyToManyField(Tag, related_name='tag_collections')
+
+ def __unicode__(self):
+ return self.name
+
# A related_name is required on one of the ManyToManyField entries here because
# they are both addressable as reverse relations from Tag.
class Entry(models.Model):
@@ -102,5 +109,17 @@ FieldError: Cannot resolve keyword 'porcupine' into field. Choices are: id, name
>>> w.save()
>>> w.delete()
+# Regression for #11956 -- You can add an object to a m2m with the
+# base class without causing integrity errors
+>>> c1 = TagCollection.objects.create(name='c1')
+>>> c1.tags = [t1,t2]
+
+>>> c1 = TagCollection.objects.get(name='c1')
+>>> c1.tags.all()
+[<Tag: t1>, <Tag: t2>]
+
+>>> t1.tag_collections.all()
+[<TagCollection: c1>]
+
"""
}