Hello,
After you mentioned this on #django, I went on hacking something as I told you. I'm not sure what are the guidelines in this list for posting code, so I'll just paste below, since dpaste can vanish eventually. Please forgive me since this is my first post. Let me know and it won't happen again ;-)) Check if this is sort of what you had in mind... Currently, it prints on screen (I was using the shell) but you could of course easily change that for whatever suits your needs. I haven't tested much, but seems to work fine with ForeignKey() and ManyToManyField(). == start cutting here == # # you can also find this in... http://dpaste.com/hold/27861/ # from django.newforms.models import model_to_dict def model_to_human(model): d = model_to_dict(model) for (k, v) in d.items(): try: # test for relation manager value = unicode(eval('model.'+k+'.all()')) except AttributeError: # nope, not that! # let's prettify the output Django-style inst = str(eval('model.'+k+'.__class__')) fullClass = inst.split(' ')[1][1:-2] # gets "<class '(. +)'>" splitted = fullClass.split('.') value = str(eval('model.'+k)) if len(splitted) > 1: # this is not a builtin type, so we can prettify it className = splitted[-1] # gets last dotted part value = '<'+ className +': '+ value +'>' print str(k) +': '+ value == end cutting here == Hope it helps, Eduardo "IdNotFound" On Dec 12, 5:13 pm, Milan Andric <[EMAIL PROTECTED]> wrote: > Is there an easy way to print an object in html? Basically with > display names and manytomany relationships resolved. (just for > viewing) > > I was thinking to write something like model_to_dict(obj) that > resolves a bunch of stuff and makes it more readable. But returns a > big html string similar to printing a form but without input fields. > > Anything like that exist already? > > -- > Milan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---