Skip to content

Commit

Permalink
Better docs
Browse files Browse the repository at this point in the history
Update installation.rst
  • Loading branch information
baseplate-admin committed Feb 24, 2024
1 parent c9421c7 commit a6c5c9a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 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
3 changes: 2 additions & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Installation

.. code-block:: python
# settings.py
INSTALLED_APPS = [
...,
"django_ltree",
Expand All @@ -31,5 +32,5 @@ Installation
3. Run migrations:

.. code-block:: sh
./manage.py migrate

0 comments on commit a6c5c9a

Please sign in to comment.