Sunday, January 29, 2012

Re: about QuerySet

On Jan 20, 10:12 am, newme <> wrote:
> user = User.objects.filter(pk="XXXX")
> user is a QuerySet
> every time i call user[0], i returns a different reference.
> maybe it should be a python question.
> i want to know i QuerySet does that.

The reason is that Django does not do "instance caching". That is, you
will get different reference each time from a queryset because that is
how it works. If you need to use the same instance, then you need to
store that somewere yourself. This is all the help I can give based on
your question.

- Anssi

You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment