Issue 7: DOM like functions
Status:  WontFix
Owner: ----
Closed:  Jan 2008
Reported by peac...@gmail.com, Jan 10, 2008
Type: Enhancement
Priority: Medium

Hi,

I think these two things taken from the DOM model would be very handy for
the mptt model interface:

  * parent field
    n = Node.geti(id=1)
    if not n.is_root():
      print n.parent.name

  * add_child(node)
    n = Node(name='new child')
    Node.get(id=1).add_child(n)

Thanks.
Jan 10, 2008
Project Member #1 jonathan.buchanan
(No comment was entered for this change.)
Labels: -Type-Defect Type-Enhancement
Jan 10, 2008
#2 peac...@gmail.com
Sorry I forgot that there is already a parent column which have to be defined in the
model fields. 
Jan 14, 2008
Project Member #3 jonathan.buchanan
I think putting in an add_child method would be unnecessary, as the Django ORM
already provides a way to do this through the backward relationship [1], which people
will already be used to and which works with MPTT:

   Node.get(pk=1).children.create(name='New child')

[1] http://www.djangoproject.com/documentation/db-api/#backward
Status: WontFix