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.
Installation
-
Install the package:
You can install
django-simple-nav
using pip: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.
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.