Skip to main content

Navigation system for django sites

Project description

https://badge.fury.io/py/django-lineup.svg https://travis-ci.org/otto-torino/django-lineup.svg?branch=master https://codecov.io/gh/otto-torino/django-lineup/branch/master/graph/badge.svg https://static.pepy.tech/badge/django-lineup

Multiple navigation system for django sites.

Django Lineup lets you manage a tree of items. Each first level node represents a menu you can include in your templates.

images/lineup.png

Documentation

The full documentation is at https://django-lineup.readthedocs.io.

Quickstart

Install Django Lineup:

pip install django-lineup

Add it to your INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'lineup.apps.LineupConfig',
    ...
)

Add to your main urls.py:

...
path("lineup/", include("lineup.urls", namespace="lineup")),
...

Make sure the requests context processor is included (it is by default):

TEMPLATES = [
  {
    'OPTIONS': {
      'context_processors': [
        "django.template.context_processors.request",
      ],
    },
  },
]

Render a menu::

{% load lineup_tags %}
{% lineup_menu 'my-root-item-slug '%}

Render the breadcrumbs::

{% load lineup_tags %}
{% lineup_breadcrumbs 'my-root-item-slug '%}

Import a menu from a json::

$ python manage.py import_menu_from_json

Json example::

{
  "label": "Main Menu",
  "slug": "main-menu",
  "order": 0,
  "children": [
    {
      "label": "Tools",
      "slug": "tools",
      "order": 0,
      "children": [
        {
          "label": "DNS Tools",
          "slug": "dns-tools",
          "order": 0,
          "login_required": true,
          "children": [
            {
              "label": "DMARC DNS Tools",
              "slug": "dmarc-dns-tools",
              "link": "/dmarc-tools/",
              "title": "DMARC Rulez",
              "order": 0
            }
          ]
        },
        {
          "label": "Password Generator",
          "slug": "password-generator",
          "order": 1
        }
      ]
    },
    {
      "label": "Disabled Item",
      "slug": "disabled-item",
      "order": 1,
      "enabled": false,
      "children": [
        {
          "label": "Disabled child",
          "slug": "disabled-child",
          "order": 0
        }
      ]
    },
    {
      "label": "Perm Item",
      "slug": "perm-item",
      "order": 2,
      "permissions": [
        "add_permission",
        "view_session"
      ]
    }
  ]
}

Features

  • Multiple menus supported

  • Visibility logic: login required / permissions

  • Render menu tree templatetags

  • Breadcrumbs templetetag

  • Import a menu from json management command

  • Rebuild tree button in admin

  • Django Baton integration to highlight different menu in the admin

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install -r requirements_test.txt
(myenv) $ python runtests.py

Development commands

pip install -r requirements_dev.txt
invoke -l

Example app

This example is provided as a convenience feature to allow potential users to try the app straight from the app repo without having to create a django project.

It can also be used to develop the app in place.

To run this example, follow these instructions:

  1. Navigate to the root directory of your application (same as manage.py)

  2. Install the requirements for the package:

    pip install -r requirements_test.txt

  3. Make and apply migrations

    python manage.py makemigrations

    python manage.py migrate

  4. Run the server

    python manage.py runserver

  5. Access from the browser at http://127.0.0.1:8000

  6. Admin user account is admin:admin

Credits

Django Lineup is developed by Otto SRL.

Tools used in rendering this package:

History

1.0.0 (2025-06-26)

  • Fix migrations (breaking change)

  • Fix active menu item class

0.3.4 (2024-06-18)

  • Fix caching with multiple menus

0.3.3 (2024-06-18)

  • Improve overall performance

  • Add cache

0.3.2 (2024-05-30)

  • Adds rebuild command in admin

0.3.1 (2022-12-22)

  • Adds Dajngo 4 support

0.3.0 (2021-04-27)

  • Adds the extras field

0.2.3 (2021-02-28)

  • Fixes tests

0.2.2 (2021-02-28)

  • Fixes baton row attributes method

0.2.1 (2020-12-14)

  • Adds order field as editable in change list page

  • First stable release

0.2.0 (2020-12-14)

  • First stable release

0.1.0 (2020-12-11)

  • First release on PyPI.

Project details


Download files

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

Source Distribution

django_lineup-1.0.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

django_lineup-1.0.0-py2.py3-none-any.whl (15.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django_lineup-1.0.0.tar.gz.

File metadata

  • Download URL: django_lineup-1.0.0.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for django_lineup-1.0.0.tar.gz
Algorithm Hash digest
SHA256 aea94f39a6c1eb76e5e38a1103770fec7dda54c8e69765c665f2b526f8942624
MD5 30c17aa37bb577cc3d44ceeb57dc61dc
BLAKE2b-256 bde77fa26da5cf4618084dd459a705b6d77208e1c6725df8ced8a3fd93259469

See more details on using hashes here.

File details

Details for the file django_lineup-1.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: django_lineup-1.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for django_lineup-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 63d4b76608b1df618be9359abbbf71a75996990d8f5fca9bc71b59af40f02455
MD5 54d8d9c4e332f0111430c79006061833
BLAKE2b-256 6b8e7443111c5824e56f10b080d09843204d336078077f8846f77d1c5f5e3ac6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page