mirror of
https://github.com/django/django.git
synced 2025-10-27 15:46:10 +00:00
Fixed #16048 -- Use the base manager instead of the default manager to retrieve a related object of a GenericForeignKey similar to ForeignKeys. Thanks, adurdin.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16261 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -4,7 +4,7 @@ from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from models import (TaggedItem, ValuableTaggedItem, Comparison, Animal,
|
||||
Vegetable, Mineral)
|
||||
Vegetable, Mineral, Gecko)
|
||||
|
||||
|
||||
class GenericRelationsTests(TestCase):
|
||||
@@ -223,6 +223,11 @@ class GenericRelationsTests(TestCase):
|
||||
self.assertEqual(u''.join(form.as_p() for form in formset.forms), u"""<p><label for="id_x-0-tag">Tag:</label> <input id="id_x-0-tag" type="text" name="x-0-tag" maxlength="50" /></p>
|
||||
<p><label for="id_x-0-DELETE">Delete:</label> <input type="checkbox" name="x-0-DELETE" id="id_x-0-DELETE" /><input type="hidden" name="x-0-id" id="id_x-0-id" /></p>""")
|
||||
|
||||
def test_gfk_manager(self):
|
||||
# GenericForeignKey should not use the default manager (which may filter objects) #16048
|
||||
tailless = Gecko.objects.create(has_tail=False)
|
||||
tag = TaggedItem.objects.create(content_object=tailless, tag="lizard")
|
||||
self.assertEqual(tag.content_object, tailless)
|
||||
|
||||
class CustomWidget(forms.CharField):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user