1 May 2008 01:55
Identify fieldmodel for attributes of an given object
Manuel Meyer <manuel <at> dpsgmuenster.de>
2008-04-30 23:55:44 GMT
2008-04-30 23:55:44 GMT
Hey,
I want to get the Fieldmodel(Charfield, TextField, SlugField...) of
each member of any given object.
What I have now is this:
def search_objects_attributes(o):
object_dir = dir(o)
for i in object_dir:
try:
current_attribute = getattr(o, i)
except:
continue
if type(current_attribute) == type(u''):
print i+': '+str(current_attribute.__class__)+' '+str
(len(current_attribute))+' '+current_attribute.encode('utf-8')[:300]
This code get every member, that is represented as unicode string,
but I'd like to know, if it was defined as TextField, CharField....
How this is possible?
Thanks, Manuel
--~--~---------~--~----~------------~-------~--~----~
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 <at> googlegroups.com
To unsubscribe from this group, send email to django-users-unsubscribe <at> googlegroups.com
(Continue reading)
RSS Feed