On Fri, Dec 4, 2009 at 10:01 AM, John Wang <[email protected]> wrote:
> Hi all,
>
> let me express my question more simple and easy to understand.As we
> know we can access the manager B through A as the following:
>
>>>> manager_of_b = a.b_set # get the manager of B
>>>> queryset_b = manager_of_b.all() # get all instance of B
>
> now how can I access the manager of A through class B? e,g I want to:
>
>>>> manager_of_a = B.some_api_i_dont_know
>>>> queryset_a = manager_of_a.all()
>>> B.fk.field.rel.to
will effectively return you the class "A", so
>>> B.fk.field.rel.to.all()
will return all instances of A.
You can also get this by inspecting the _meta attribute of B:
>>> B._meta.get_field('fk').rel.to
Yours,
Russ Magee %-)
--
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.