ContentType and model instances with deferred fields
Suppose we have model like this:
class Entry(models.Model):
title = models.CharField(max_length=128)
body = models.TextField()
>>> from blog.models import Entry
>>> # creating new entry object
>>> Entry.objects.create(title="test entry", body="some body content")
>>> entry_1 = Entry.objects.get(title="test entry")
>>> entry_2 = Entry.objects.defer('body').get(title="test entry")
>>> from django.contrib.contenttypes.models import ContentType
>>> ContentType.objects.get_for_model(e1)
<ContentType: entry>
>>> ContentType.objects.get_for_model(e2)
<ContentType: entry_ deferred_body>
ContentTypes
for the same model instances with and without deferred fields are not the same (I suppose that's because they're not instances of the same class and have different _meta.object.name
value). I'm not sure if that's the correct behavior. I mean - does the instance with deferred field(s) should have different ContentType
?
I found this issue when i tried use django-tagging and it's template tag tags_for_object
with 'deferred QuerySet
'. But maybe described behavior is correct and that's django-tagging bug?
Fixed in r10523.