I am trying to retrieve the root nodes of a hierarchy. My nodes look like this:
class MyNode(MPTTModel):
parent = TreeForeignKey('self', blank=True, null=True,
related_name='children')
slug = models.SlugField(max_length=100, unique=True)
title = models.CharField(max_length=100)
user = models.ForeignKey(User)
and I call
MyNode.tree.filter(level=0)
to retrieve the root nodes as the documentation says here: http://django-mptt.github.io/django-mptt/technical_details.html#level
But when I execute that code, I get this error:
AttributeError: type object 'MyNode' has no attribute 'tree'
What object am I supposed to use to retrieve the root nodes then? Thank you!