Get a list of attributes for a django object

This post was written 6 years ago.
Mon, 10 Oct 2011
For a queryset:
myobj.objects.filter(foo=bar)
myobj.values()[0].keys()

For a single object instance:-
for field in speaker._meta.fields:
print field.name

Also for a single object instance - returns fields and values as a dict
speaker.__dict__

Iterate through the dict like above:
for k,v in speaker.__dict__.iteritems():
print k,v

This post was written 6 years ago, which in internet time is really, really old. This means that what is written above, and the links contained within, may now be obsolete, inaccurate or wildly out of context, so please bear that in mind :)