But why do you need to get that value via the *field* object? The usual way to do it is simply to access the attribute directly on the model instance:unicode(dev.distro)or, if you have the field name as a string as you imply originally, use `getattr`:unicode(getattr(dev, 'distro'))
Indeed, that's what I am doing now:
for field in Device._meta.fields:
vname = field.verbose_name
val = unicode(getattr(dev, field.name))
val = sanitized_value(val)
self.stdout.write("%s: %s\n" % (vname, val))
Thank you all.
-- You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/vTfXKM6K914J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment