I'm trying, without a great deal of success, to perform a simple self join using the django orm. I'm pretty sure the F() function is not the answer. I believe this only allows you to compare two field within the same model instance, not to compare fields within 2 instances of the same model. I want to do this -
Model- class Account(models.Model): name = models.CharField(max_length=255) parent_account = models.ForeignKey('self', default=None, blank=True) SQL- SELECT account.*, parent.* FROM account LEFT JOIN account parent ON account.id = parent.parent_account This seems pretty basic, but I can't find any way to do it. 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-us...@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.