An example is better than a thousand words:
In [3]: User.objects.filter(id=19)[0] == User.objects.filter(id=19)[0]
Out[3]: True
In [4]: User.objects.filter(id=19)[0] == User.objects.filter(id=19).defer('email')[0]
Out[4]: False
Does it work like this on purpose ?
Subquestion: is there any simple way to get a regular model instance from the deferred one ?
EDIT:
It looks like contenttypes framework is patched appropriately: http://code.djangoproject.com/changeset/10523
so I would say that the Model.__eq__() operator shouldn't look like this:
def __eq__(self, other):
return isinstance(other, self.__class__) and self._get_pk_val() == other._get_pk_val()
but more like this:
def __eq__(self, other):
return ContentType.objects.get_for_model(self) is ContentType.objects.get_for_model(other) and self._get_pk_val() == other._get_pk_val()
This of course causes two DB hits for the first time, but fortunately get_for_model seems to implement cache.