[Answer]-Add a new root node to django-mptt tree

1👍

A tree has one root node. If you’re trying to add a new root node, it means adding a new tree. django-mptt supports either having one tree (just only create one root node), or a whole forest of trees.

You basically never need to use .move_to(), unless you’re doing something really special like manually-user-ordered nodes. Just set the parent to None. I don’t know much about FactoryBoy but the usual way to create a new root node is just:

MyNode.objects.create(name='NewRoot', parent=None)

Leave a comment