Re: basci question about queryset for retrieving top element

2012-04-17 Thread NENAD CIKIC
Thanks, I will check On 18 Apr, 04:34, HarpB wrote: > Like > thishttp://readthedocs.org/docs/django/en/latest/py-modindex.html?highlig... > or perhaps thishttp://djangoapi.quamquam.org/trunk/? > > There is also a great book:http://www.djangobook.com/en/2.0/ -- You received

Re: basci question about queryset for retrieving top element

2012-04-17 Thread HarpB
Like this http://readthedocs.org/docs/django/en/latest/py-modindex.html?highlight=django or perhaps this http://djangoapi.quamquam.org/trunk/ ? There is also a great book: http://www.djangobook.com/en/2.0/ -- You received this message because you are subscribed to the Google Groups "Django

Re: basci question about queryset for retrieving top element

2012-04-17 Thread NENAD CIKIC
OK, thanks Always learning. What I miss from my other programming is MSDN like style of help pages. I tend more and more to use the django pdf documentation because I can't get used to the web interface for this. On 17 Apr, 07:42, HarpB wrote: > Both patterns will produce

Re: basci question about queryset for retrieving top element

2012-04-16 Thread HarpB
Both patterns will produce same query. You can also use django-debug-toolbar, which gives ur debugsqlshell tool. So you can execute code from the commandline and can see what the query will be. Django also has a code pattern for your case - for getting the first element, you can just use

Re: basci question about queryset for retrieving top element

2012-04-16 Thread NENAD CIKIC
OK, thanks for sharing this On 16 Apr, 07:54, Pavan Verma wrote: > I am a Django newbie and also interested in this question. > > From reading the Django bookhttp://www.djangobook.com/en/2.0/chapter05/, > I see that the query 'Publisher.objects.order_by('name')[0:2]' maps

Re: basci question about queryset for retrieving top element

2012-04-15 Thread Pavan Verma
I am a Django newbie and also interested in this question. >From reading the Django book http://www.djangobook.com/en/2.0/chapter05/, I see that the query 'Publisher.objects.order_by('name')[0:2]' maps to: SELECT id, name, address, city, state_province, country, website FROM books_publisher

basci question about queryset for retrieving top element

2012-04-14 Thread NENAD CIKIC
Hello! I want to get just the top element of one queryset. SO I have something as qs=MyModel.objects.filter(...).order_by(..) and then use qs[0] and check some value I wonder now if i did the right thing or it is better to use .extra on queryset. Is the queryset object allocated for all objects,

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

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__`

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

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

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

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

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'}]

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

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

about QuerySet

2012-01-27 Thread newme
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. -- You received this message because you are subscribed to the Google Groups "Django users" group. To

Re: Question about QuerySet and Pagination

2011-09-29 Thread Felix Wagner
Thank you very much for your help On Sep 29, 4:25 pm, Tom Evans wrote: > On Thu, Sep 29, 2011 at 3:16 PM, Felix Wagner > wrote: > > Ok, so now i have: > > .. > >             > ... > > Now if i click next page I get an empty page because: >

Re: Question about QuerySet and Pagination

2011-09-29 Thread Tom Evans
On Thu, Sep 29, 2011 at 3:16 PM, Felix Wagner wrote: > Ok, so now i have: > .. >             ... > Now if i click next page I get an empty page because: > http://127.0.0.1:8000/search/?page=2, > > I probably need a url entry and do i have to give the poaginator the >

Re: Question about QuerySet and Pagination

2011-09-29 Thread Felix Wagner
Ok, so now i have: template: {% block coltype %}colMS{% endblock %} {% block content %} Suche Search: {% if query %} Resultate für "{{ query|escape }}": {% if results %}

Re: Question about QuerySet and Pagination

2011-09-29 Thread Tom Evans
On Thu, Sep 29, 2011 at 8:36 AM, Felix Wagner wrote: > Hello, > > I'm currently trying to paginate my results from a search query. > > views.py: > > def search(request): >    query = request.GET.get('q', '') > >    if query: >        qset = ( >            

Question about QuerySet and Pagination

2011-09-29 Thread Felix Wagner
Hello, I'm currently trying to paginate my results from a search query. views.py: def search(request): query = request.GET.get('q', '') if query: qset = ( Q(NAME__icontains=query) ) results = Thin_Client.objects.filter(qset).distinct() else:

Re: question about queryset count function

2008-11-14 Thread kaos
thanks ive been reading the documentation constantly, i just couldnt seem to find that particular tidbit ;] loving django On Nov 15, 5:50 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Fri, 2008-11-14 at 20:26 -0800, kaos wrote: > > [...] > > > Will that return the count of all of the

Re: question about queryset count function

2008-11-14 Thread Malcolm Tredinnick
On Fri, 2008-11-14 at 20:26 -0800, kaos wrote: [...] > Will that return the count of all of the articles in the given > category using a COUNT(*) query, or will it actually pull ALL of the > articles from the database and get the size of the array? > > Basically i'm trying to figure out if im

question about queryset count function

2008-11-14 Thread kaos
Hi, I am new to Django (and python), and I have a question regarding database query stuff Basic info - I have a category model and an article model, and each article is linked to a category through a foreign key If i have the following code --- category = Category.objects.all()[0] return