This doesn’t work:
>>> pa = Person.objects.all()
>>> pa[2].nickname
u'arst'
>>> pa[2].nickname = 'something else'
>>> pa[2].save()
>>> pa[2].nickname
u'arst'
But it works if you take
p = Person.objects.get(pk=2)
and change the nick.
Why so.
DB queried to give you a Person object
DB queried again to give you yet another Person object.
Let’s call this instance PersonObject1 that resides in memory. So it’s equivalent to something like this:
Now let’s do this:
The pa[2] again queries a db an returns Another instance of person object, say PersonObject2 for example. Which will be unchanged! So it’s equvivalent to calling something like:
But this has nothing to do with PersonObject1.