Re: flat values() in querysets

2006-08-04 Thread Will McCutchen
Adrian Holovaty wrote: > Sounds pretty good to me. Let's do it. I opened a ticket and submitted a patch: http://code.djangoproject.com/ticket/2482 My patch adds a keyword arguement to the 'values' method, as originally proposed. It could be adapted pretty easily to Gary's suggestion of a separa

Re: flat values() in querysets

2006-08-03 Thread Gary Wilson
Adrian Holovaty wrote: > Oooh, that's a nice idea. I'm not 100% certain "flat=True" is the best > name for it, but I can't think of anything better at the moment. Would > you be willing to submit a patch? Maybe .flatvalues("id", "name") or .valuelist("id", "name") ? --~--~-~--~~

Re: flat values() in querysets

2006-08-03 Thread Adrian Holovaty
On 8/3/06, Daniel Poelzleithner <[EMAIL PROTECTED]> wrote: > What do you think about returning n tupples for n arguments. if n > 1 > and a pure list for only one argument ? > > .values("id", "name", flat=True) would return > [(id,name),(id,name),...] > > .values("id", flat=True) would return > [id

Re: flat values() in querysets

2006-08-03 Thread Daniel Poelzleithner
jrs wrote: > What would the result be if multiple fields were selected? or should > this be valid only when a single field is requested? > > NetworkState.objects.all().order_by("-stopdate")[:5].values("id", > "name") I couldn't think of a nice solution at first, so i said for one key only. Wh

Re: flat values() in querysets

2006-08-03 Thread jrs
What would the result be if multiple fields were selected? or should this be valid only when a single field is requested? NetworkState.objects.all().order_by("-stopdate")[:5].values("id", "name") --~--~-~--~~~---~--~~ You received this message because you are su

Re: flat values() in querysets

2006-08-03 Thread Adrian Holovaty
On 8/3/06, Daniel Poelzleithner <[EMAIL PROTECTED]> wrote: > >>> NetworkState.objects.all().order_by("-stopdate")[:5].values("id") > [{'id': 2738}, {'id': 2737}, {'id': 2736}, {'id': 2735}, {'id': 2734}] > > Then i have to unpack it to get a [2738, 2737,...] list, which is what I > wanted in the f

flat values() in querysets

2006-08-03 Thread Daniel Poelzleithner
Hi, Currently it's kinda verbose to get just a list of id's from a query to put it in a bulk_in or process it further. example: >>> NetworkState.objects.all().order_by("-stopdate")[:5].values("id") [{'id': 2738}, {'id': 2737}, {'id': 2736}, {'id': 2735}, {'id': 2734}] Then i have to unpack it