Skip to main content

Wagtail Nav Menus is a app to provide highly customizable menus in wagtail by leveraging StreamFields.

Why

Remember when websites had tree structures with logical menus that followed the same structure? For many those days are gone. We are asked to create arbitrary menu items, place value props in menus that aren’t even links, and build highly interactive menus with Javascript.

Wagtail Nav Menus addresses this by using stream fields to support arbitrary items in the menu and gives you options to render the menus as both django templates or json for your js tooling to consume.

demo.png

Built in Components

  • Nav Category - a grouping of other components - for things like sub navigation

  • Page Link - Link to a wagtail Page

  • External Link - Django URLField link

  • Django Link - Reverse django view lookups

  • Relative URL - Regex enforced relative links

  • Image

  • Html

Install

  1. Install wagtail-nav-menus with pip.

  2. Add wagtail_nav_menus to INSTALLED_APPS.

Settings

You can add other streamfields like this:

from wagtail_nav_menus.defaults import WAGTAIL_NAV_MENU_TYPES_DEFAULT

WAGTAIL_NAV_MENU_TYPES = WAGTAIL_NAV_MENU_TYPES_DEFAULT + [
    ('page_link_with_image', 'nav_menus_ext.models', 'InternalPageImageBlock'),
    ('page_link_with_image', 'nav_menus_ext.models', 'NavAdvertBlock'),
]

The schema here is (‘name’, ‘module_path’, ‘class name’)

Edit menu name choices. The default is top and footer. These represent different menus for your webpage. The names are arbitrary - but you will look them up by name in templates.

WAGTAIL_NAV_MENU_CHOICES_DEFAULT = (
    ("top", "Top"),
    ("footer", "Footer"),
)

Usage

Nav Menus should appear in wagtail’s settings sidebar tab. CMS uses can control them here.

You may use some template tags to use these in your site.

get_nav_menu

Use this to insert the menu using django templates:

{% load nav_menu_tags %}
{% get_nav_menu 'footer' %}

See the [templates folder](wagtail_nav_menus/templates/) in this repo for examples of rendering the menu. You will want to copy these into your project’s template folder to extend them.

get_nav_menu_json

Use this to get the menu as a json object.

{% load nav_menu_tags %}
{% get_nav_menu_json 'top' as top %}
<div data-menu='{{ top }}'></div>

API Usage

If using Django Rest Framework to access the menu data, this module provides some tools to get started.

Add NavMenuViewSet to your Rest Framework Router.

from wagtail_nav_menus.viewsets import NavMenuViewSet

Release files for wagtail-nav-menus 3.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wagtail-nav-menus 3.1.2
File Size Uploaded
wagtail-nav-menus-3.1.2.tar.gz 15.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wagtail-nav-menus 3.1.2
File Interpreter ABI Platform
wagtail_nav_menus-3.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 35.4 kB

Release files / wagtail-nav-menus-3.1.2.tar.gz

Download URL wagtail-nav-menus-3.1.2.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f185ab334779abf7df5a7894cea4ff4f74b94d47f508b21a5a586f8e54f54015
BLAKE2b-256 checksum
How to use checksums
e881e591b31f46803916fde5a55918bfa8678a57eae050d4eb0b2bf90f581d01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5rc1

Release files / wagtail_nav_menus-3.1.2-py3-none-any.whl

Download URL wagtail_nav_menus-3.1.2-py3-none-any.whl
Size 20.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ec372d100f34a34777958ef90614e442946339569fe9fde3eb8c786462542571
BLAKE2b-256 checksum
How to use checksums
c2ae9073f5007f3990bc11be91c6cf0430623e23319602c0098f30660dd2e07b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5rc1

Release history Release notifications | RSS feed

3.14.0

2 release files

3.12.1

2 release files

3.11.1

2 release files

3.11.0

2 release files

3.10.1

2 release files

3.10.0

2 release files

3.9.2

2 release files

3.9.0

2 release files

3.8

2 release files

3.7

2 release files

3.6

2 release files

3.5

2 release files

3.4

2 release files

3.3

2 release files

3.2

2 release files

This release

3.1.2 This release

2 release files

3.1.1

2 release files

3.1

2 release files

3.0

2 release files

2.0.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page