Am 05.12.2012 um 11:23 schrieb Axel Rau:
> 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?
>
model_field.rel.to.__name__
does the trick.
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.