• radiac.net
  • Projects
  • django-style
    • Documentation

django-style

django-style

Contents:

  • Demo
  • Installation
  • Usage
  • Menus
    • Nav object
    • Example usage
  • Changelog
  • Contributing
django-style
  • »
  • Menus
  • View page source

Menus

The themes have basic support for a simple single-level menu in the header and footer.

Define your links in your template context with site_nav for header links, and footer_nav for footer links - see Usage.

These should be lists of objects with a url and label attribute - or a dict with those keys.

Nav object

For convenience Django Style comes with a Nav(label, view=None, url=None) object, where you provide either url as a URL string, or a view which is automatically resolved to a url using django.urls.reverse.

Example usage

from django_style import Nav

def my_view(request)
    return render(
        request,
        "my_template.html",
        context={
            "site_nav": [
                Nav("Home", "index"),
                Nav("About", "about"),
                Nav("Contact", "contact"),
            ],
            "footer_nav": [
                Nav("Privacy policy", "privacy"),
                Nav("Contact", "contact"),
            ],
        },
    )
Previous Next

© Copyright 2025, Richard Terry.

Built with Sphinx using a theme provided by Read the Docs.