Re: Creating a root object for a many-to-one relationship

2006-06-10 Thread James Bennett
On 6/10/06, Justin <[EMAIL PROTECTED]> wrote: > I toyed with the idea of a custom Manager but wanted to see first if > Django already handled this scenerio "out of the box" and I was just > missing it. Yeah, Django covers it, you just need to add 'blank=True' as well; as Luke pointed out, 'null'

Re: Creating a root object for a many-to-one relationship

2006-06-10 Thread Justin
Yeah, what I have is: class Container(models.Model): parent = models.ForeignKey('self', null=True, related_name='child') I toyed with the idea of a custom Manager but wanted to see first if Django already handled this scenerio "out of the box" and I was just missing it. --~--~-~--~--

Re: Creating a root object for a many-to-one relationship

2006-06-10 Thread Luke Plant
On Saturday 10 June 2006 16:46, Todd O'Bryan wrote: > On Jun 10, 2006, at 11:41 AM, Justin wrote: > > I was following the Model Ex. 11 "Relating an object to itself, > > many-to-one" in an attempt to create nested containers. I'm running > > into the problem that at the start there is no parent f

Re: Creating a root object for a many-to-one relationship

2006-06-10 Thread arthur debert
won't this work for you: class Node(Model): parent = ForeignKey('self', blank=True, null=True) ... rest of your model... then fetch it like Node.objects.filter(parent__isnull=True) if you are worried with the possibility of ending up with mode that one root node you could do either (bot

Re: Creating a root object for a many-to-one relationship

2006-06-10 Thread Todd O'Bryan
On Jun 10, 2006, at 11:41 AM, Justin wrote: > > I was following the Model Ex. 11 "Relating an object to itself, > many-to-one" in an attempt to create nested containers. I'm running > into the problem that at the start there is no parent for newly > created > objects to relate too. Is there a w

Creating a root object for a many-to-one relationship

2006-06-10 Thread Justin
I was following the Model Ex. 11 "Relating an object to itself, many-to-one" in an attempt to create nested containers. I'm running into the problem that at the start there is no parent for newly created objects to relate too. Is there a way to handle this from the Model or do I need to just fire