pypi i django-treenav


Extensible, hierarchical, and pluggable navigation system for Django sites

by caktus

2.0.0 (see all)License:BSD
Categories:Django Tree
pypi i django-treenav


.. sidebar:: Build Status

:master: |master-status| :develop: |develop-status|

An extensible, hierarchical, and pluggable navigation system for Django sites.

django-treenav was designed from the start to live independent of a CMS implementation. As a separate application, treenav can easily be integrated into existing, custom setups and does not enforce or require users to use a particular content management system.

Sharing the same principles, django-pagelets <>_ integrates seamlessly with treenav and can be used together to create a flexible CMS product.

For complete documentation checkout, <>_

.. |master-status| image:: :alt: Build Status :target:

.. |develop-status| image:: :alt: Build Status :target:


  • Generic functionality with multiple URL specifications: get_absolute_url(), reverse(), or raw URLs
  • Packaged with templates to render the tree hierarchy with nested <ul>'s, but can easily be overridden with custom templates
  • Easily customize each item's template or fall back to a default menuitem.html
  • Useful CSS classes for flexible UI customization
  • Automatically sets "active" on item and item's parents if PATH_INFO is equal to item.href
  • Efficient: minimizes database access with django-mptt functionality
  • Caches the tree so that repeated page views do not hit the database.
  • Simple links in the MenuItem list view for refreshing the cache and href from the database.


  • django <>_ >= 2.2
  • django-mptt <>_ >= 0.11.0

Using the demo

For a quick demo, follow these steps:

  1. Create a virtualenv. (This example uses mkvirtualenv, but there are many other ways to do it)::

    $ mkvirtualenv django-treenav

#. Check out the code and install the requirements::

 (django-treenav)$ git clone git://
 (django-treenav)$ cd django-treenav/
 (django-treenav)~/django-treenav/$ pip install -Ur dev-requirements.txt

#. Run migrations and create a superuser so you can login to the Django admin::

 (django-treenav)~/django-treenav$ python migrate
 (django-treenav)~/django-treenav$ python createsuperuser

#. Run the server::

 (django-treenav)~/django-treenav$ python runserver

#. Visit http://localhost:8000/ in your browser and follow the instructions.


#. Install the app with pip::

pip install django-treenav

#. Add to your INSTALLED_APPS and run migrate::


#. Include these context processors::

    'OPTIONS': {
      'context_processors': [

#. Add these urls::

urlpatterns = [
    url(r'^treenav/', include('treenav.urls')),

Maintainer Information

We use Github Actions to lint (using pre-commit, black, isort, and flake8), test (using tox and tox-gh-actions), calculate coverage (using coverage), and build documentation (using sphinx).

We have a local script to do these actions locally, named

$ ./

A Github Action workflow also builds and pushes a new package to PyPI whenever a new Release is created in Github. This uses a project-specific PyPI token, as described in the PyPI documentation here <>_. That token has been saved in the PYPI_PASSWORD settings for this repo, but has not been saved anywhere else so if it is needed for any reason, the current one should be deleted and a new one generated.

As always, be sure to bump the version in treenav/ before creating a Release, so that the proper version gets pushed to PyPI.

Development sponsored by Caktus Consulting Group, LLC <>_.

2yrs ago
5yrs ago
6yrs ago
7yrs ago
No alternatives found
No tutorials found
Add a tutorial
No dependencies found

Rate & Review

No reviews found
Be the first to rate