Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#10738 closed (fixed)

ContentType and model instances with deferred fields

Reported by: tomasz.elendt Owned by: nobody
Component: Database layer (models, ORM) Version: 1.1-beta
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


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 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?

Attachments (3)

deferred_model_contenttype.diff (1.2 KB ) - added by tomasz.elendt 15 years ago.
deferred_model_contenttype.2.diff (571 bytes ) - added by tomasz.elendt 15 years ago.
deferred_model_contenttype_tests.diff (611 bytes ) - added by tomasz.elendt 15 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by anonymous, 15 years ago

Version: 1.01.1-beta-1

by tomasz.elendt, 15 years ago

comment:2 by tomasz.elendt, 15 years ago

Has patch: set
Needs tests: set

by tomasz.elendt, 15 years ago

by tomasz.elendt, 15 years ago

comment:3 by tomasz.elendt, 15 years ago

Needs tests: unset

comment:4 by Malcolm Tredinnick, 15 years ago

Resolution: fixed
Status: newclosed

Fixed in r10523.

comment:5 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top