mirror of
https://github.com/django/django.git
synced 2025-04-01 12:06:43 +00:00
Added test to demonstrate issue 11263 isn't there anymore.
Thanks veena for the report and jaklaassen for the patch. Fixes #11263.
This commit is contained in:
parent
5f7eecd09a
commit
c4b6659269
@ -94,3 +94,7 @@ class GeckoManager(models.Manager):
|
|||||||
class Gecko(models.Model):
|
class Gecko(models.Model):
|
||||||
has_tail = models.BooleanField()
|
has_tail = models.BooleanField()
|
||||||
objects = GeckoManager()
|
objects = GeckoManager()
|
||||||
|
|
||||||
|
# To test fix for #11263
|
||||||
|
class Rock(Mineral):
|
||||||
|
tags = generic.GenericRelation(TaggedItem)
|
||||||
|
@ -6,7 +6,7 @@ from django.contrib.contenttypes.models import ContentType
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from .models import (TaggedItem, ValuableTaggedItem, Comparison, Animal,
|
from .models import (TaggedItem, ValuableTaggedItem, Comparison, Animal,
|
||||||
Vegetable, Mineral, Gecko)
|
Vegetable, Mineral, Gecko, Rock)
|
||||||
|
|
||||||
|
|
||||||
class GenericRelationsTests(TestCase):
|
class GenericRelationsTests(TestCase):
|
||||||
@ -231,6 +231,16 @@ class GenericRelationsTests(TestCase):
|
|||||||
tag = TaggedItem.objects.create(content_object=tailless, tag="lizard")
|
tag = TaggedItem.objects.create(content_object=tailless, tag="lizard")
|
||||||
self.assertEqual(tag.content_object, tailless)
|
self.assertEqual(tag.content_object, tailless)
|
||||||
|
|
||||||
|
def test_subclasses_with_gen_rel(self):
|
||||||
|
"""
|
||||||
|
Test that concrete model subclasses with generic relations work
|
||||||
|
correctly (ticket 11263).
|
||||||
|
"""
|
||||||
|
granite = Rock.objects.create(name='granite', hardness=5)
|
||||||
|
TaggedItem.objects.create(content_object=granite, tag="countertop")
|
||||||
|
self.assertEqual(Rock.objects.filter(tags__tag="countertop").count(), 1)
|
||||||
|
|
||||||
|
|
||||||
class CustomWidget(forms.TextInput):
|
class CustomWidget(forms.TextInput):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user