You should actually use dir() or vars() rather than __dict__. Here's a thorough explanation, along with an example serializer which might need to access an object's attributes:
http://blog.enterthefoo.com/2008/08/pythons-vars.html Regards, André Terra On Tue, Jul 12, 2011 at 4:52 PM, Marc Aymerich <glicer...@gmail.com> wrote: > On Tue, Jul 12, 2011 at 7:25 PM, Lukich <luk...@gmail.com> wrote: > > Hi. I have just started diving into Django and this question came up > > - is there a way for me to examine all the attribute values of an > > object? In Rails there's such a thing as debug statement which spits > > out all the details about the object. From what I have seen so far in > > Django, I can either do a __unicode__() trick, but it forces me to > > specify which attribute to show. I also read about dir() and > > __dict__, but they show me sets of attributes without their values. Is > > there something I'm missing? Thank you! > > Hi Luka, > I get the object attributes and their values with __dict__, It's not > enough for your case? > > >>> Domain.objects.all()[1].__dict__ > {'name_ptr_id': 2L, 'name': u'pangea', 'extension': u'org', > 'slave_refresh': u'1d', 'min_caching_time': u'1h', '_state': > <django.db.models.base.ModelState object at 0x3351090>, 'is_mail': > False, 'slave_retry': u'2h', 'is_hosted': False, 'expire': > datetime.date(2012, 7, 31), 'active': True, 'is_purchased': False, > 'slave_expiration': u'4w', 'id': 2L, 'serial': 203308L} > > -- > Marc > > -- > 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. > > -- 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.