Django Lineage

screenshot of Django Lineage

Lightweight template tags for neater hierarchical navigation

Overview

Django Lineage is a navigation element system that determines the active state of a navigation element in a template by inspecting the page URL. It provides a simple way to add an "active" class to the navigation element that corresponds to the current page.

Features

  • Active Navigation Element: Determines the active state of a navigation element by comparing the URL with the defined ancestor.
  • Installation: Easily install Django Lineage using pip and add it to your project's settings.
  • Usage: Load the ancestor tag into your template and use it to determine the active state of the navigation element.
  • Variable and Filter Support: The ancestor tag can handle variables, filters, and other complex arguments.
  • Output Customization: Customize the output of the "active" state by altering the default phrase or overriding it on demand.
  • Dependent on URL Hierarchies: Lineage relies on sensible URL hierarchies and uses regex matching to compare paths.
  • Request Context Dependency: The request context must be present in order to determine the current URL.

Summary

Django Lineage is a useful tool for managing the active state of navigation elements in Django templates. By inspecting the page URL, Lineage can determine which navigation element corresponds to the current page and apply an "active" class to it. This allows for easy styling and user feedback. Installation is simple through pip, and usage involves adding the ancestor tag to the template. Overall, Django Lineage is a powerful and efficient solution for active navigation management.