Sunday, January 29, 2012

Re: about QuerySet

On Jan 20, 10:12 am, newme <dllizh...@gmail.com> 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 django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment