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 I can't figure it out, and I can't find any documentation on the > matter. > > basically I want to be able to do this: > > class Foo(models.Model): > bar = model.CharField(max_length=20) > barfoo = model.ForeignKey(Bar) > > foo = Foo.objects.get(pk=1) > foo.get_dictionary() > {'barfoo': 1, 'bar': 'bar value'}
There might be a better way, but try taking a look at foo._meta._fields It does't give you exactly what you need, but the pieces are there. Jay P. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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-users?hl=en -~----------~----~----~----~------~----~------~--~---