Package: greendeploy-django-ltree
===================
greendeploy-django-ltree.. image::https://img.shields.io/github/actions/workflow/status/GreenDeploy-io/greendeploy-django-ltree/main.yml?branch=main&style=for-the-badge:target:https://github.com/GreenDeploy-io/greendeploy-django-ltree/actions?workflow=CI.. image::https://img.shields.io/badge/Coverage-100%25-success?style=for-the-badge:target:https://github.com/GreenDeploy-io/greendeploy-django-ltree/actions?workflow=CI.. image::https://img.shields.io/pypi/v/greendeploy-django-ltree.svg?style=for-the-badge:target:https://pypi.org/project/greendeploy-django-ltree/.. image::https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge:target:https://github.com/psf/black.. image::https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=for-the-badge:target:https://github.com/pre-commit/pre-commit:alt: pre-commitThe authoritative and broadly useful Django package for using Postgres
ltree fields in your Django models, designed to be transparent and
accessible for Django beginners.WelcomeWelcome to greendeploy-django-ltree, your go-to package for handling PostgreSQL
ltree fields in a Django project. We're mindful of the end-to-end context and
aim to make this package not just a code repository buta complete learning
experience.We aim to achieve this in three ways:Beginner-friendly documentation: We specifically tailor the
documentation to help Django newcomers and include end-to-end
demonstrations that make no assumptions about your prior knowledge of
ltree or materialized paths.Quick, early wins in 10 mins each: We have picked 3 base cases as early
wins for you. Each of these should take you no more than 10 mins to
complete, including reading the docs.Install in sandbox project: We show you how to install the package
in a sandbox project and create the field in your Postgres database.Add materialized path in ltree field: We show you how to add data
to your ltree field using your Django ORM.Query ltree field: We show you how to query your ltree field using
Django ORM.Active maintenance: We are committed to maintaining this package and
keeping it up to date with the latest Django, Python, and Postgres versions.
We have plans to measure the mean time to close the Github issues and will
reveal them in the near future.About ltreeltreeis a data type in Postgres database. It is a tree-like structure
where each node is alabel. The label can be a string or a number.Thus, the piece of data is basically astring of labels separated by dots.
Also known as alabelpath.A label consists ofA-Za-z0-9_and can be up to 255 characters long.The length of a label path is a maximum 65535 labels long.An example of a label path isTop.Countries.Europe.RussiawhereTopis the
root node andRussiais the leaf node.There's another name for label path that's more better known which isMaterialized Pathcoined byVadim Tropashko <http://vadimtropashko.wordpress.com/>__
inSQL Design Patterns <http://www.rampant-books.com/book_0601_sql_coding_styles.htm>__.Some good resources to read on the subject are:Postgres' owndocumentation <https://www.postgresql.org/docs/current/ltree.html>__Vadim Tropashko'sNested Sets and Materialized Path SQL Trees <http://www.rampant-books.com/art_vadim_nested_sets_sql_trees.htm>__django-treebeard'sMaterialized Path trees <https://django-treebeard.readthedocs.io/en/latest/mp_tree.html>_RequirementsPostgres 15 supported.Python 3.8 to 3.11 supported.Django 4.2 supported.SetupInstall frompip:.. code-block:: shpython -m pip install greendeploy-django-ltreeand then add it to your installed apps:.. code-block:: pythonINSTALLED_APPS = [
    ...,
    "greendeploy-django-ltree",
    ...,
]Make sure you add the trailing comma or you might get aModuleNotFoundError(seethis blog post <https://adamj.eu/tech/2020/06/29/why-does-python-raise-modulenotfounderror-when-modifying-installed-apps/>__).You will also need to rundjango_ltreemigrations before you added thePathField.See Quick Start below and in documentation for more details.Aboutdjango-ltree(Github repository <https://github.com/mariocesar/django-ltree>__) was
created in March 2020 by Mario-César. It went unmaintained from August 2021.Kimsia Sim was motivated to fork it under the namegreendeploy-django-ltreein September 2023
and make it support Django 4.2. The reason is that Kimsia needed to use it in a Django 4.2 project.The pypi package name is undergreendeploy-django-ltree <https://pypi.org/project/greendeploy-django-ltree/>__ and formally
published on 11th September 2023.greendeploy-django-ltreehas hadclose to 10 contributors <https://github.com/greendeploy-io/greendeploy-django-ltree/graphs/contributors>__
in its time; gratitude and a big thank you to every one of them.Quick Start@TODO: Add quick start here.