Re: Query for cascading children to a parent

2007-10-08 Thread [EMAIL PROTECTED]
Thanks.. I think that will work.. will try it out shortly! On Oct 8, 11:08 am, "Richard Dahl" <[EMAIL PROTECTED]> wrote: > I have a model class 'Organization' with a parent and I do this with a > method get_child_orgs: > > get_child_orgs(self): > child_orgs = [] > co =

Re: Query for cascading children to a parent

2007-10-08 Thread Richard Dahl
I have a model class 'Organization' with a parent and I do this with a method get_child_orgs: get_child_orgs(self): child_orgs = [] co = Organization.objects.filter(parent__exact = self) for c in co: child_orgs.append(c) gc = c.get_child_orgs()

Re: Query for cascading children to a parent

2007-10-08 Thread Thomas Guettler
Am Montag, 8. Oktober 2007 15:13 schrieb [EMAIL PROTECTED]: > In my model class I have: > > class Company(models.Model): > company_id = models.AutoField(primary_key=True) > parent_company = models.ForeignKey("self",null=True) > . > . > > > How would I query to get back all

Re: Query for cascading children to a parent

2007-10-08 Thread Malcolm Tredinnick
On Mon, 2007-10-08 at 13:31 +, [EMAIL PROTECTED] wrote: > Ok..thanks.. I was afraid I was going to get that answer. If I do > this with select_related, I'm still going to have to implement a loop > to display them all in one list, because they'd come back as >

Query for cascading children to a parent

2007-10-08 Thread [EMAIL PROTECTED]
In my model class I have: class Company(models.Model): company_id = models.AutoField(primary_key=True) parent_company = models.ForeignKey("self",null=True) . . How would I query to get back all children companies, as well as all of their children companies, and their children