Every list page in Horilla sits under a navbar the search box, the view-type switcher, the filter toggle, the action dropdown. Like list views, tabs, detail views, and filters, navbars have their own extension point: _inherit_nav, living under horilla/extension/nav/.

Worth being upfront, same as with the tab post earlier in this series: _inherit_nav currently has zero production consumers in this codebase. It’s fully implemented, tested, wired into the bootstrap sequence, and guarded by Django system checks it shipped as part of the same release that added _inherit_card, _inherit_filter, and _inherit_nav together but no app in this checkout actually registers one. Even the documentation’s own example app, my_lead_extensions/navbars.py, doesn’t exist anywhere in the repo; the project’s own spec document checks it off as done, which isn’t accurate as of this version. So treat the example below as the mechanism’s documented reference case, not a pattern copied from a live feature.

What Does the Extension Mechanism Do?

_inherit_nav lets a NavExtension subclass in a separate app:

  • Append an extra action to the navbar’s action dropdown
  • Add an entry to the “view type” switcher dropdown
  • Exclude a field from the column selector or kanban field list
  • Override any method on the target navbar most usefully things like new_button with ordinary super() calls

The base class is HorillaNavView:

class HorillaNavView(TemplateView):
    """View for rendering the navigation bar with filtering and search capabilities."""
    template_name = "navbar.html"
    ...

and every concrete navbar in the app LeadNavbar, UserNavbar, LoginHistoryNavbar, and 60-odd others subclasses it directly:

class LeadNavbar(LoginRequiredMixin, HorillaNavView):

Interestingly, HorillaNavView also has its own get_filterset_class(), mirroring the one on HorillaListView from the earlier filter post navbars can carry a filterset_class for parity with the list view they sit above, and that resolution goes through the exact same _inherit_filter resolver already covered.

Defining a Nav Extension

The documented pattern, straight from Horilla CRM‘s own quick-start:

# my_lead_extensions/navbars.py
from horilla.extension.nav import NavExtension


class LeadNavbarExtension(NavExtension):
    _inherit_nav = "horilla_crm.leads.views.core.LeadNavbar"

    column_selector_exclude_fields_append = ["industry_code"]

Same registration mechanics as every other kind in this series setting _inherit_nav on a NavExtension subclass triggers __init_subclass__, which registers the extension the moment the class body executes.

Registering the Extension App

# my_lead_extensions/apps.py

auto_import_modules = [
    "models",
    "forms",
    "filters",
    "navbars",   # required — registers NavExtension at import
    "lists",
    "kanbans",
    "details",
]

# local_settings.py

INSTALLED_APPS += ["my_lead_extensions"]

Understanding the Configuration

  • _inherit_nav — dotted path to a concrete HorillaNavView subclass. Targeting HorillaNavView itself is explicitly rejected there’s a dedicated system check (nav_extensions.E004) for exactly this mistake.
  • _inherit_nav_priority — default 0; higher runs later in the composed MRO, winning any conflicts.
  • Layout hooks — the declarative additive attributes: actions_append (adds an entry to the navbar’s action dropdown), custom_view_type_update (merges into the view-type switcher), column_selector_exclude_fields_append, exclude_kanban_fields_append, and navbar_indication_attrs_update.
  • Scalar overrides — a separate set of plain flag attributes you can override wholesale rather than append to: things like filterset_class, default_layout, enable_quick_filters, enable_actions, filter_option, search_option, all_view_types, nav_width, and a handful of others.
  • Method overrides — anything else callable on the class body becomes a mixin method with correctly rebound super() chaining.

It’s worth noting what’s not here: there’s no generic “insert a menu item” hook like list’s columns_insert. The only menu-shaped hook is actions_append, scoped to the navbar’s own action dropdown not a sidebar or main-navigation tree.

Overriding a Method

The documented example for a method override adds a check before falling back to the original behavior:

class LeadNavbarExtension(NavExtension):

class LeadNavbarExtension(NavExtension):
    _inherit_nav = "horilla_crm.leads.views.core.LeadNavbar"

    @cached_property
    def new_button(self):
        if not self.request.user.has_perm("leads.add_lead"):
            return None
        return super().new_button

As with every other extension kind in this series, super() here works correctly even though the method is composed into a dynamically built mixin rather than inherited the ordinary way Horilla rebinds each copied method’s __class__ closure cell to the mixin it actually lives in, so the call chains to the next extension (or the real target) regardless of how many extensions are stacked.

How Resolution Works

HorillaNavView.as_view() wraps the view in a resolver, structurally identical to the list and tab mechanisms:

def view(request, *args, **kwargs):
    resolved = resolve_nav_view_class(cls)
    fingerprint = nav_fingerprint()

    if resolved is not cls:
        if (
            getattr(view, "_extended_handler", None) is None
            or getattr(view, "_extended_cls", None) is not resolved
            or getattr(view, "_nav_ext_fingerprint", None) != fingerprint
        ):
            view._extended_cls = resolved
            view._extended_handler = resolved.as_view(**initkwargs)
            view._nav_ext_fingerprint = fingerprint
        return view._extended_handler(request, *args, **kwargs)
    return base_view(request, *args, **kwargs)

The docstring on this method explains why it re-resolves per request rather than at import time: “Target apps register navbar URLs in AppLauncher.ready() before extension apps import navbars.py; resolving only at URL-import time would miss extensions.” The registry fingerprint check means a late-loading extension app is picked up without needing a process restart resolution happens on the next request after the extension registers, not only at server startup.

As with _inherit_tab, resolution here is an exact match only — there’s no MRO/base-class fallback. Registering against LeadNavbar extends LeadNavbar specifically; it won’t cascade to any other navbar, and you can’t register against the shared HorillaNavView base to reach every navbar at once the way _inherit_list can for list views.

A Documentation Gap Worth Knowing

The project’s own internal spec document checks off “documented in extension index + my_lead_extensions/navbars.py” as a completed acceptance criterion. That file doesn’t exist anywhere in this codebase it’s the same hypothetical example app referenced in the quick-start, treated internally as if it were a real, shipped reference implementation.

If you go looking for a working example to copy, you won’t find one; the quick-start in the docs is the only reference that exists, and it has been spot-checked here against the actual compose.py/metaclass.py code, so it’s accurate even though it’s unused.

_inherit_nav gives navbars the same extension shape as the rest of the series a small NavExtension subclass, registered via auto_import_modules, composed in automatically per request with append-style hooks for actions and view-type options, scalar overrides for behavior flags, and ordinary method overrides for anything else.

It’s solid, tested infrastructure sitting unused: a good option to reach for the day a client needs to add one action to one specific navbar, but not yet proven by a real app the way _inherit_list and _inherit_filter are.

Share this article