On Dec 4, 2007 12:57 AM, Gary Wilson <[EMAIL PROTECTED]> wrote:
> But what would the situation be with a new limit() method...
>
> objects = MyModel.objects.filter(site=1)
> first_one = objects.limit(1)
> do_something_special(first_one)
> return render_to_response('t.html', {'objects': objects, 'first': first_one})
>
> If limit() returns a new QuerySet, you're still going to have two queries.

No -- I guess I didn't explain myself well enough. In this case, I
wouldn't use limit(). I have two goals:

    * Retrieve all objects in the table.
    * Do something special with the first one (once the whole list has
been retrieved).

The ideal API would look like this, and it would only run a single query:

    objects = MyModel.objects.filter(site=1)
    first_one = objects[0]

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to