Metadata-Version: 2.1
Name: django-mptt2
Version: 0.2.0
Summary: Utilities for implementing Modified Preorder Tree Traversal with your Django Models and working with trees of Model instances.
Home-page: https://github.com/jokiefer/django-mptt2/
Author: Jonas Kiefer
Author-email: jonas.kiefer@live.com
License: MIT-License
Platform: OS Independent
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Topic :: Software Development :: Libraries
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.2
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Python: >=3.8
Description-Content-Type: text/x-rst
Provides-Extra: tests
License-File: LICENSE

.. image:: https://readthedocs.org/projects/django-mptt2/badge/?version=latest
    :target: https://django-mptt2.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation Status

.. image:: https://badge.fury.io/py/django-mptt2.svg
    :target: https://pypi.org/project/django-mptt2/
    :alt: PyPi version

django-mptt2
============
Based on the idea of the unmaintained `django-mptt <https://github.com/django-mptt/django-mptt>`_ package i implemented this new code base to replace it.

Cause no other package fits all of my use cases, which are primary in fast reading tree's from the database, i started working on this project.

There is an alternative to this package, called `django-treebeard <https://pypi.org/project/django-treebeard/>`_, which implements nested sets as well, but without a parent foreignkey.


Quick-Start
-----------

Install it as any other django app to your project:

.. code-block:: bash

    $ pip install django-mptt2

Add `django-mptt2` to `INSTALLED_APPS`:

.. code-block:: python

    INSTALLED_APPS = [
        # other apps
        "mptt2"
    ]

Inheritance from the abstract `mptt2.models.Node` Model:

.. code-block:: python

    from django.db import models
    from mptt2.models import 
    
    class Genre(Node)
        name = models.CharField(max_length=50, unique=True)


Adding nodes:

.. code-block:: python

    from project.models import Genre

    rock = Genre(name="Rock")
    rock.insert_at() # it will become the root node without target parameter

    metal = Genre(name="Metal")
    metal.insert_at(target=rock) # it will become the last child from rock 

    alternative = Genre(name="Alternative")
    alternative.insert_at(target=rock) # it will become the last child from rock, the right sibling of metal


For full usage description, please read the tutorial section of our `documentation <https://django-mptt2.rtfd.io>`_.
