On Tue, Jan 24, 2012 at 03:51:27AM -0800, katstevens wrote:
Obviously the 'val = obj.get_field_display()' line doesn't work!

Is there a generic way of doing this (something like
obj.get_display(fieldname) ?) or am I going to have to hard code
separate checks for get_country_display() and
get_dialing_code_display()?

I think you can do what you want like this:

        obj = queryset[my_item]

        for field in obj._meta.fields:
                if field.choices:
                    val = obj._get_FIELD_display(field)
                else:
                    val = getattr(obj, field.name)
                row.append(val)

--
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