Monday, October 28, 2013

Re: Backwards relation not showing up via related_name in inherited models

On Monday, 28 October 2013 15:11:24 UTC, Joshua Orvis wrote:
Thank you for responding, that's extremely helpful.  I'm still failing to query against it though.  How would I implement a query for the get_children() method in the example above?  That is, for any given instance of FlowBlueprint how do I get all objects with a relation to it?

The point is that unless the M2M field has `symmetrical=False`, there's only one side of the relation, which is `parents`. So in this case you would just do `self.parents.all()`. That said, for a parent/child relationship like this you probably do want to set symmetrical to False, in which case `self.children.all()` would work.
--
DR.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e90e7e9e-8426-4e20-95df-807edabc18f9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment