Obtaining related model name during form creation
In __init__ in my form class I have:
for name, field in self.fields.items():
model_field = self.instance._meta.get_field_by_name(name)[0]
if isinstance(field, forms.models.ModelChoiceField): # foreign key
x = getattr(self.instance, name, '') # representation of related instance
How can I obtain the class name of related model?
Axel
---
PGP-Key:29E99DD6 ☀ +49 151 2300 9283 ☀ computing @ chaos claudius
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home