Google Groups Home
Help | Sign in
Message from discussion flat values() in querysets
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Adrian Holovaty  
View profile
 More options Aug 3 2006, 2:30 pm
From: "Adrian Holovaty" <holov...@gmail.com>
Date: Thu, 3 Aug 2006 13:30:32 -0500
Local: Thurs, Aug 3 2006 2:30 pm
Subject: Re: flat values() in querysets
On 8/3/06, Daniel Poelzleithner <goo...@poelzi.org> 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 first place.

> I suggest Object.objects.all().values("id", flat=True). Flat as a
> optional argument, which is only allowed when only one field is
> requested and returns a list with only the values.

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?

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google