summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2008-09-02 15:26:00 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2008-09-02 15:26:00 +0000
commit79d2ee3b6d405674a2a49f0884312a8cdc82d809 (patch)
treefbb5bdc0b773664b2518c15b33f5341d7fec633c /tests
parent98e1cc92f47cbda977a923b9ba8d980bc01cd749 (diff)
Fixed #8309: subclasses now inherit `GenericForeignKey` correctly. There's also now an internal API so that other "virtual fields" like GFK can be inherited as well. Thanks, msaelices.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8855 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/generic_relations/models.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/modeltests/generic_relations/models.py b/tests/modeltests/generic_relations/models.py
index 2f36e268e0..db5ae47581 100644
--- a/tests/modeltests/generic_relations/models.py
+++ b/tests/modeltests/generic_relations/models.py
@@ -27,6 +27,9 @@ class TaggedItem(models.Model):
def __unicode__(self):
return self.tag
+class ValuableTaggedItem(TaggedItem):
+ value = models.PositiveIntegerField()
+
class Comparison(models.Model):
"""
A model that tests having multiple GenericForeignKeys
@@ -204,6 +207,12 @@ __test__ = {'API_TESTS':"""
>>> Comparison.objects.all()
[<Comparison: tiger is stronger than None>]
+# GenericForeignKey should work with subclasses (see #8309)
+>>> quartz = Mineral.objects.create(name="Quartz", hardness=7)
+>>> valuedtag = ValuableTaggedItem(content_object=quartz, tag="shiny", value=10)
+>>> valuedtag.save()
+>>> valuedtag.content_object
+<Mineral: Quartz>
# GenericInlineFormSet tests ##################################################