Skip to main content
Documentation Status PyPi version

django-mptt2

Based on the idea of the unmaintained 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, which implements nested sets as well, but without a parent foreignkey.

Quick-Start

Install it as any other django app to your project:

$ pip install django-mptt2

Add django-mptt2 to INSTALLED_APPS:

INSTALLED_APPS = [
    # other apps
    "mptt2"
]

Inheritance from the abstract mptt2.models.Node Model:

from django.db import models
from mptt2.models import

class Genre(Node)
    name = models.CharField(max_length=50, unique=True)

Adding nodes:

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_mptt2-0.3.0.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_mptt2-0.3.0-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file django_mptt2-0.3.0.tar.gz.

File metadata

  • Download URL: django_mptt2-0.3.0.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for django_mptt2-0.3.0.tar.gz
Algorithm Hash digest
SHA256 8ffb27bf0d10298d519cc3d0672a47f3a7ccebdd663ced41b098ba4348905d05
MD5 a982ed5b3a49ab5d39c2db6b05f56869
BLAKE2b-256 3a7fecb099e3866574dc60d679dd670afbf4ba49a8b3f661619b6441d4ed99bd

See more details on using hashes here.

File details

Details for the file django_mptt2-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: django_mptt2-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for django_mptt2-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 30ae2b5db0cf41f0879c677d9246c1e11a332575dde9e4358b3cf6efdfbf2b87
MD5 aa9093d69adc98a81989f5f7aba59b30
BLAKE2b-256 462409c24aeae4fcd5879f58fa46f090bb430cb543bf646bdccc985e0e670654

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page