Hi developers - your review would be appreciated here! It seems to me, based on my experimentation, that if I have an intermediary model that has a many-to-many relationship from the model to itself, that the order of the two fields that point back to the model is important. For example:
class Task(models.Model): child_tasks = models.ManyToManyField('self', null=True, blank=True, through='Membership', symmetrical=False, related_name="parent_tasks") class Membership(models.Model): parent_task = models.ForeignKey(Task, related_name='parent_memberships') child_task = models.ForeignKey(Task, related_name='child_memberships') percentage = models.DecimalField(default=0, max_digits=5, decimal_places=2) Assuming I have my models defined as above, then if I do: Task.objects.filter(subtasks__isnull=False) Then I get a select that looks like this: select <columns> from taskmanager_task INNER JOIN taskmanager_membership ON (taskmanager_task.id = taskmanager_membership.parent_task_id) However, if I change the order of parent_task and child_task in the Membership class (ie, make child_task first), then the select is different: select <columns> from taskmanager_task INNER JOIN taskmanager_membership ON (taskmanager_task.id = taskmanager_membership.child_task_id) The doc does not really describe this, as far as I can see. Developers - is this something I should post as a bug ticket or am I missing something? The doc does say that the two foreign keys will be treated as the two (different) sides of the many-to-many relation, so I have a feeling this is an attempt to touch on this point. Anyway, just trying to confirm that this is expected behavior and whether it would be worthwhile for me to post a bug ticket on it for better doc. Thanks! -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.