Re: dumb question model-dictionary

2008-09-02 Thread bruno desthuilliers
On 2 sep, 10:18, "James Bennett" <[EMAIL PROTECTED]> wrote: > On Tue, Sep 2, 2008 at 2:30 AM, bruno desthuilliers > > <[EMAIL PROTECTED]> wrote: > > More seriously, it took me 2 minutes playing with a model object in > > the interactive shell to come up with what seems a working solution: > > Yeah

Re: dumb question model-dictionary

2008-09-02 Thread Bülent Aldemir
Or >>> foo = Foo.objects.values().get(pk=1) >>> type(foo) 2008/9/1 Malcolm Tredinnick <[EMAIL PROTECTED]> > > > On Mon, 2008-09-01 at 15:10 -0400, Jay Parlar wrote: > > On Mon, Sep 1, 2008 at 2:48 PM, Vance Dubberly <[EMAIL PROTECTED]> > wrote: > > > > > > So I'm finding there are multiple plac

Re: dumb question model-dictionary

2008-09-02 Thread Vance Dubberly
Bruno, thanks that 2 mins of yours was exactly what I was looking for. I feel much worse about myself and much better about the world in general, which is the way things should be, thanks! Does seem odd that there is no such method in Model already but that it's in ModelForm instead. Oh well ea

Re: dumb question model-dictionary

2008-09-02 Thread James Bennett
On Tue, Sep 2, 2008 at 2:30 AM, bruno desthuilliers <[EMAIL PROTECTED]> wrote: > More seriously, it took me 2 minutes playing with a model object in > the interactive shell to come up with what seems a working solution: Yeah, which is why I pointed out the easy wrapper function for it in my email

Re: dumb question model-dictionary

2008-09-02 Thread bruno desthuilliers
On 2 sep, 05:24, "Vance Dubberly" <[EMAIL PROTECTED]> wrote: > Wow. I guess it wasn't such a stupid question. > > foo._meta.fields .. each field will give me att names but not values. Getting an attribute by name is dead simple in Python - use getattr(). > All the methods on the fields that lo

Re: dumb question model-dictionary

2008-09-01 Thread James Bennett
On Mon, Sep 1, 2008 at 10:24 PM, Vance Dubberly <[EMAIL PROTECTED]> wrote: > Hmm perhaps I should do > > foo = Foo.objects.filter(pk=1) > foo_form = FooForm(instance=foo) > data = foo_form.cleaned_data Or you could do what the form itself is doing, namely, using the function django.forms.models.

Re: dumb question model-dictionary

2008-09-01 Thread Vance Dubberly
Wow. I guess it wasn't such a stupid question. foo._meta.fields .. each field will give me att names but not values. All the methods on the fields that look like they return values only return the values you give them, WTF? Foo.objects.filter(pk=1).values()[0] requires 2 calls to the database

Re: dumb question model-dictionary

2008-09-01 Thread Malcolm Tredinnick
On Mon, 2008-09-01 at 15:10 -0400, Jay Parlar wrote: > On Mon, Sep 1, 2008 at 2:48 PM, Vance Dubberly <[EMAIL PROTECTED]> wrote: > > > > So I'm finding there are multiple places where I'm needing to iterate > > over the properties of a Model and I'm absolutely certain it's got to > > be insanely

Re: dumb question model-dictionary

2008-09-01 Thread Jay Parlar
On Mon, Sep 1, 2008 at 2:48 PM, Vance Dubberly <[EMAIL PROTECTED]> wrote: > > So I'm finding there are multiple places where I'm needing to iterate > over the properties of a Model and I'm absolutely certain it's got to > be insanely easy to get a dictionary from a model but for the life of > me

dumb question model-dictionary

2008-09-01 Thread Vance Dubberly
So I'm finding there are multiple places where I'm needing to iterate over the properties of a Model and I'm absolutely certain it's got to be insanely easy to get a dictionary from a model but for the life of me I can't figure it out, and I can't find any documentation on the matter. basically