Ticket #16048: ticket16048-r16259.diff
File ticket16048-r16259.diff, 2.4 KB (added by , 13 years ago) |
---|
-
tests/modeltests/generic_relations/tests.py
4 4 from django.test import TestCase 5 5 6 6 from models import (TaggedItem, ValuableTaggedItem, Comparison, Animal, 7 Vegetable, Mineral )7 Vegetable, Mineral, Gecko) 8 8 9 9 10 10 class GenericRelationsTests(TestCase): … … 223 223 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> 224 224 <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>""") 225 225 226 def test_gfk_manager(self): 227 # GenericForeignKey should not use the default manager (which may filter objects) #16048 228 tailless = Gecko.objects.create(has_tail=False) 229 tag = TaggedItem.objects.create(content_object=tailless, tag="lizard") 230 self.assertEqual(tag.content_object, tailless) 226 231 227 232 class CustomWidget(forms.CharField): 228 233 pass -
tests/modeltests/generic_relations/models.py
78 78 79 79 def __unicode__(self): 80 80 return self.name 81 82 class GeckoManager(models.Manager): 83 def get_query_set(self): 84 return super(GeckoManager, self).get_query_set().filter(has_tail=True) 85 86 class Gecko(models.Model): 87 has_tail = models.BooleanField() 88 objects = GeckoManager() -
django/contrib/contenttypes/models.py
100 100 method. The ObjectNotExist exception, if thrown, will not be caught, 101 101 so code that calls this method should catch it. 102 102 """ 103 return self.model_class()._ default_manager.using(self._state.db).get(**kwargs)103 return self.model_class()._base_manager.using(self._state.db).get(**kwargs) 104 104 105 105 def natural_key(self): 106 106 return (self.app_label, self.model)