Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
how to list fields in a model?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
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
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
hotani  
View profile  
 More options Jun 20 2006, 2:12 am
From: "hotani" <hot...@gmail.com>
Date: Mon, 19 Jun 2006 23:12:11 -0700
Local: Tues, Jun 20 2006 2:12 am
Subject: how to list fields in a model?
According to the docs, this should return a dictionary:

model.objects.filter(id=5).values()

However, none of the normal dictionary methods work on it, like say
"keys()."

Basically I'd like to grab an entire object and convert it to a
dictionary so I can work with it, is this possible?


    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.
Malcolm Tredinnick  
View profile  
 More options Jun 20 2006, 2:25 am
From: Malcolm Tredinnick <malc...@pointy-stick.com>
Date: Tue, 20 Jun 2006 16:25:48 +1000
Local: Tues, Jun 20 2006 2:25 am
Subject: Re: how to list fields in a model?

On Mon, 2006-06-19 at 23:12 -0700, hotani wrote:
> According to the docs, this should return a dictionary:

> model.objects.filter(id=5).values()

Not quite: it returns something that acts like a list of dictionaries,
since there is no guarantee that your QuerySet will always contain a
single object.

> However, none of the normal dictionary methods work on it, like say
> "keys()."

In light of the above, try model.objects.filter(id=5).values()[0].keys()

Best wishes,
Malcolm


    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.
End of messages
« Back to Discussions « Newer topic     Older topic »

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