django-simple-menu
is an entirely code based menu system, because, who
really wants to define their menus inside Django Admin?..
It's simple to use, yet provides enough flexibility to provide unlimited children menus, per-request generation and checking of menu items, badges, and more.
Requirements: Python 3.6+, Django 3.2+
Note: While this package does support Python 3.6 and 3.7 as well as Django 4.0, we do not test the package under these versions and may miss some bugs.
- Install the
django-simple-menu
package. - Add
simple_menu
to yourINSTALLED_APPS
.- please ensure that you have
django.template.context_processors.request
listed underTEMPLATES[...]["OPTIONS"]["context_processors"]
.
- please ensure that you have
- Create
menus.py
inside each app you want to create a menu for and define said menus using theMenu
andMenuItem
classes you can import from thesimple_menu
package. - In your templates, load the template tags (
{% load simple_menu %}
) and call{% generate_menu %}
inside a block. Your context will be populated with a new object namedmenus
. You can now iterate over it to render your menus.
To quickly see django-simple-menu
in action, check out the
example project.
Full documentation, including installation and configuration instructions, is available at https://django-simple-menu.readthedocs.io/.
django-simple-menu
is released under the BSD 2-Clause "Simplified" License.
If you like it, please consider contributing!
django-simple-menu
was originally created by
Evan Borgstom <[email protected]> and was further developed by many
contributors.