Trivialni zobrazovatko TreeNode.
This commit is contained in:
parent
0a737390b4
commit
7ad91da45c
1 changed files with 8 additions and 0 deletions
|
@ -1152,6 +1152,14 @@ class TreeNode(models.Model):
|
|||
blank = True,
|
||||
on_delete=models.SET_NULL,
|
||||
verbose_name="další element na stejné úrovni")
|
||||
|
||||
def print_tree(self,indent=0):
|
||||
print("{}TreeNode({})".format(" "*indent,self.id))
|
||||
if self.first_child:
|
||||
self.first_child.print_tree(indent=indent+2)
|
||||
if self.succ:
|
||||
self.succ.print_tree(indent=indent)
|
||||
|
||||
|
||||
class RocnikNode(TreeNode):
|
||||
class Meta:
|
||||
|
|
Loading…
Reference in a new issue