Re: about QuerySet

2012-02-07 Thread newme
thank you so much. On Feb 7, 8:58 pm, Daniel Roseman wrote: > On Tuesday, 7 February 2012 11:36:04 UTC, newme wrote: > > > thank you. > > then a basic python question. > > how does queryset implement it? > > does python also allow operator (e.g. []) overloading? > > It's not usually called overlo

Re: about QuerySet

2012-02-07 Thread Daniel Roseman
On Tuesday, 7 February 2012 11:36:04 UTC, newme wrote: > > thank you. > then a basic python question. > how does queryset implement it? > does python also allow operator (e.g. []) overloading? > > It's not usually called overloading in Python, but yes. Classes can define a `__getitem__` method

Re: about QuerySet

2012-02-07 Thread newme
thank you. then a basic python question. how does queryset implement it? does python also allow operator (e.g. []) overloading? On Feb 3, 5:29 pm, akaariai wrote: > On Feb 3, 5:52 am, newme wrote: > > > so it means when i call user[1] after user[0], it is possible that i > > will get same record

Re: about QuerySet

2012-02-03 Thread akaariai
On Feb 3, 5:52 am, newme wrote: > so it means when i call user[1] after user[0], it is possible that i > will get same record if someone else insert a new record into database > between 2 calls. Actually, there doesn't need to be an insert between the calls if you don't use .order_by(). Technic

Re: about QuerySet

2012-02-02 Thread newme
so it means when i call user[1] after user[0], it is possible that i will get same record if someone else insert a new record into database between 2 calls. On Feb 1, 5:34 pm, akaariai wrote: > On Feb 1, 9:36 am, newme wrote: > > > do you mean that queryset will query database every time i call

Re: about QuerySet

2012-02-01 Thread Daniel Roseman
On Wednesday, 1 February 2012 08:34:14 UTC, akaariai wrote: > > On Feb 1, 9:36 am, newme wrote: > > do you mean that queryset will query database every time i call > > user[0]? > > Yes. That is exactly what happens: > In [7]: qs[0] > Out[7]: > In [9]: print connection.queries > [{'time': '

Re: about QuerySet

2012-02-01 Thread akaariai
On Feb 1, 9:36 am, newme wrote: > do you mean that queryset will query database every time i call > user[0]? Yes. That is exactly what happens: In [7]: qs[0] Out[7]: In [9]: print connection.queries [{'time': '0.011', 'sql': 'SELECT ... FROM "organisaatio_osa" LIMIT 1'}] In [10]: qs[0] Out[10]:

Re: about QuerySet

2012-01-31 Thread newme
do you mean that queryset will query database every time i call user[0]? On 1月30日, 午前9:29, akaariai wrote: > On Jan 20, 10:12 am, newme wrote: > > > user = User.objects.filter(pk="") > > user is a QuerySet > > > every time i call user[0], i returns a different reference. > > > maybe it shoul

Re: about QuerySet

2012-01-29 Thread akaariai
On Jan 20, 10:12 am, newme wrote: > user = User.objects.filter(pk="") > 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".