Thanks Russell, it works with the get_accessor_name() method combinated with the model attribute.
2007/8/23, Russell Keith-Magee <[EMAIL PROTECTED]>: > > > On 8/22/07, Grégoire Cachet <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I would like to get the class name from a relation name (OneToOne) > ... > > I want to get the class of the object a.modelb (ie ModelB) without > > instanciating a ModelA. Is there a clever way to get it from the model > > definition ? or do I have to check every case like : > > I'm not entirely sure I understand exactly what it is you want to do; > but you might be able to use the contents of the _meta object. In > particular, > > ModelA._meta.get_all_related_objects() > > will return you a list of RelatedObjects; these RelatedObjects are > wrappers around the models that have relations to ModelA. Digging into > the RelatedObject instances will let you do things like: > > [r.model for r in ModelA._meta.get_all_related_objects()] > > which will be a list of the classes that have relations to ModelA. > > Yours, > Russ Magee %-) > > > > -- Grégoire --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

