﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
10695	defer() uses the same cached value for all models	jbronn	Malcolm Tredinnick	"While trying to get `defer()` to work with `GeoQuerySets` I ran into some strange issues.  I eventually figured out that that problem was not isolated to !GeoDjango.  Here a toy model that demonstrates the problem:

{{{
from django.db import models

class City(models.Model):
    name = models.CharField(max_length=30)
    def __unicode__(self): 
        return self.name
}}}

Creating two cities, and showing what happens when the `QuerySet` is evaluated:
{{{
>>> c = City.objects.create(name='Pueblo')
>>> c = City.objects.create(name='Houston')
>>> City.objects.all()
[<City: Pueblo>, <City: Houston>]
}}}

However, when evaluating a `QuerySet` with the `name` field deferred, this is what's returned:
{{{
>>> City.objects.defer('name')
[<City_Deferred_name: Pueblo>, <City_Deferred_name: Pueblo>]
}}}

Notice how it shows ""Pueblo"" for both records, when the second one should be ""Houston.""  The same thing happens with slicing:
{{{
>>> qs = City.objects.defer('name')
>>> qs[0].name
u'Pueblo'
>>> qs[1].name
u'Pueblo'
}}}

My gut tells me that when `DeferredAttribute` is cached it is somehow cached for ''all'' of the other attributes.  However, I cannot pinpoint how and/or where this is happening."		closed	Database layer (models, ORM)	dev		fixed	defer qs		Accepted	1	0	0	0	0	0
