Skip to content

Commit

Permalink
Better docs
Browse files Browse the repository at this point in the history
  • Loading branch information
baseplate-admin committed Feb 24, 2024
1 parent c9421c7 commit c45f6a9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions django_ltree/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@


class TreeManager(models.Manager):
def get_queryset(self):
def get_queryset(self) -> TreeQuerySet["TreeModel"]:
"""Returns a queryset with the models ordered by `path`"""
return TreeQuerySet(model=self.model, using=self._db).order_by("path")

def roots(self) -> models.QuerySet["TreeModel"]:
def roots(self) -> TreeQuerySet["TreeModel"]:
"""Returns the roots of a given model"""
return self.filter().roots()

def children(self, path: str) -> models.QuerySet["TreeModel"]:
def children(self, path: str) -> TreeQuerySet["TreeModel"]:
"""Returns the childrens of a given object"""
return self.filter().children(path)

def create_child(
self, parent: "TreeModel" = None, **kwargs
) -> models.QuerySet["TreeModel"]:
) -> TreeQuerySet["TreeModel"]:
"""Creates a tree child with or without parent"""
paths_in_use = parent.children() if parent else self.roots()
prefix = parent.path if parent else None
Expand Down

0 comments on commit c45f6a9

Please sign in to comment.