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

django-mptt is installed automatically as an internal dependency; it does not need to be added to your project’s INSTALLED_APPS.

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. Apply migrations

    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:

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.1.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

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

django_lineup-1.0.1-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_lineup-1.0.1.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for django_lineup-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e66ec4498ee305e01a3ef1eed12c639fbed24effc9ec6a315c888bfb1703ccb7
MD5 acb305bb6f83b9628fdbb4ddfa95f91e
BLAKE2b-256 e7758227cda4c05c2ab2f9cda4060582e0ded33c37674a7d64cf94d0cf166489

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_lineup-1.0.1.tar.gz:

Publisher: publish.yml on otto-torino/django-lineup

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_lineup-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: django_lineup-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for django_lineup-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d8a82e9bfe49678a8aa1e174fdbca0b1a41af1d3f7c5c74e6d00965722000264
MD5 0b5ff0637dc806d9358927c4f93e9434
BLAKE2b-256 dc2f78d134f5b3c81e0039fb965723ce5a2b1776a2e65016236bc508db4569c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_lineup-1.0.1-py3-none-any.whl:

Publisher: publish.yml on otto-torino/django-lineup

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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