Here I have a silly function for pretty printing any model object's
data.

def pprint(res):

 for instr in dict(res.__dict__):
   if instr[-3:] == "_id":
      instr = instr[:-3]

   displaymeth = "get_%s_display" % instr
   try:
      atr =getattr(res,displaymeth)
   except:
      atr =getattr(res,instr)
   print "%s: %s" % (instr,atr)


It sort of prints out an easy to read representation of any model
object.  Is there a better way to do this? I am sure there was
something already in Django to do this, but I am having a hard way of
finding.  I am still on .96

Thanks, Brian Ray






--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to