Skip to main content

A simple, flexible, and extensible navigation menu for Django.

Project description

django-simple-nav

PyPI PyPI - Python Version Django Version

django-simple-nav is a Python/Django application designed to simplify the integration of navigation and menu bars in your Django projects. With a straightforward API and customizable options, you can easily add and manage navigational elements in your web applications.

Installation

  1. Install the package:

    You can install django-simple-nav using pip:

    pip install django-simple-nav
    
  2. Add to Installed Apps:

    After installation, add django_simple_nav to your INSTALLED_APPS in your Django settings:

    INSTALLED_APPS = [
        # ...
        "django_simple_nav",
        # ...
    ]
    

Usage

  1. Create a navigation definition:

    Define your navigation structure in a Python file. Here's an example configuration:

    from django_simple_nav.nav import Nav
    from django_simple_nav.nav import NavGroup
    from django_simple_nav.nav import NavItem
    
    
    class MainNav(Nav):
        template_name = "main_nav.html"
        items = [
            NavItem(title="Relative URL", url="/relative-url"),
            NavItem(title="Absolute URL", url="https://example.com/absolute-url"),
            NavItem(title="Internal Django URL by Name", url="fake-view"),
            NavGroup(
                title="Group",
                url="/group",
                items=[
                    NavItem(title="Relative URL", url="/relative-url"),
                    NavItem(title="Absolute URL", url="https://example.com/absolute-url"),
                    NavItem(title="Internal Django URL by Name", url="fake-view"),
                ],
            ),
            NavItem(
                title="is_authenticated Item", url="#", permissions=["is_authenticated"]
            ),
            NavItem(title="is_staff Item", url="#", permissions=["is_staff"]),
            NavItem(title="is_superuser Item", url="#", permissions=["is_superuser"]),
            NavItem(
                title="myapp.django_perm Item", url="#", permissions=["myapp.django_perm"]
            ),
        ]
    
  2. Integrate Navigation in Templates:

    Use the django_simple_nav template tag in your Django templates where you want to display the navigation. For example:

    {% load django_simple_nav %}
    ...
    <nav>
        {% django_simple_nav 'path.to.MainNav' %}
    </nav>
    ...
    

After configuring your navigation, you can use it across your Django project by calling the django_simple_nav template tag in your templates. This tag dynamically renders navigation based on your defined structure, ensuring a consistent and flexible navigation experience throughout your application.

License

django-simple-nav is licensed under the MIT license. See the LICENSE file for more information.

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_simple_nav-0.1.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

django_simple_nav-0.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file django_simple_nav-0.1.0.tar.gz.

File metadata

  • Download URL: django_simple_nav-0.1.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for django_simple_nav-0.1.0.tar.gz
Algorithm Hash digest
SHA256 40ee041b623a2ef546a7364f3e9abae6c69a7f1f9a31c02da4bd22ef981994c1
MD5 c82d8b8ed8c24194b3de25a23472233a
BLAKE2b-256 21085da178214302afe01c3bbfc63dd112aa160cac50b0ef75101ffc050bceca

See more details on using hashes here.

File details

Details for the file django_simple_nav-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_simple_nav-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 006df8952dfca68e8aeca9f54c4def2fcc46f0c4bac6c53bf2e8d287fdf54220
MD5 23cbf71b3bf2f4a0cec4a3b73f536739
BLAKE2b-256 996fee5410f0dbe78ad6c45537a007633ddca5322787c439b2c65f6f85a2ebd6

See more details on using hashes here.

Supported by

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