A simple, flexible, and extensible navigation menu for Django.
Project description
django-simple-nav
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.
Requirements
- Python 3.8, 3.9, 3.10, 3.11, 3.12
- Django 3.2, 4.2, 5.0
Getting Started
-
Install the package from PyPI:
python -m pip install django-simple-nav
-
Add to Installed Apps:
After installation, add
django_simple_nav
to yourINSTALLED_APPS
in your Django settings:INSTALLED_APPS = [ ..., "django_simple_nav", ..., ]
Usage
-
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"] ), ]
-
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.
Documentation
Please refer to the documentation for more information.
License
django-simple-nav
is licensed under the MIT license. See the LICENSE
file for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_simple_nav-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98a40afa3fb4d8aa6c878f4152c157ee786c7c71a740d85b4ea423ad5c71ab91 |
|
MD5 | 06bc06fe53f0b96ce529410ce5e7a968 |
|
BLAKE2b-256 | 558603c47b67ed9aa5b601691725a823ad6f23049b3f036abc23400d546e4bae |