Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
iommi 7.14.3 documentation
Logo
iommi 7.14.3 documentation
  • Getting started
  • Tutorial
  • Common config
    • after
    • assets
    • attr
    • attrs
    • auto
    • endpoints
    • extra and extra_evaluated
    • extra_params
    • include
    • iommi_style
    • name/display_name/iommi_path
    • tag
    • template
    • title/h_tag
  • Components
    • Edit tables
    • Forms
    • Fragments
    • Main menu
    • Pages
    • Queries
    • Tables
  • Cookbook
    • General
    • Parts & Pages
    • Forms
    • Tables
    • Edit tables
    • Queries
    • Porting
    • Main menu
  • Understanding iommi
    • Architecture
    • Equivalence
    • Philosophy
    • Registrations
    • Semantic models
  • Access control
  • Admin
  • API Reference
    • Action
    • Asset
    • Attrs
    • Cell
    • Cells
    • Column
    • ColumnHeader
    • Container
    • EditColumn
    • EditTable
    • Endpoint
    • Field
    • Filter
    • Form
    • FormAutoConfig
    • Fragment
    • Header
    • HeaderConfig
    • Members
    • Menu
    • MenuItem
    • Page
    • Part
    • Query
    • QueryAutoConfig
    • Style
    • Table
    • TableAutoConfig
    • Traversable
  • Dev tools
  • Add iommi to a FBV
  • Path decoding
  • Production use
  • Registrations
  • Style
  • Views
  • Imports used in the iommi documentation
  • Changelog
  • Credits
  • Contributing
  • @github
  • @discord
  • @pypi
Back to top
View this page

Main menu¶

Warning

The MainMenu component is considered experimental. That means the API can change in breaking ways in minor releases of iommi. It also means you import from iommi.experimental to make that clear.

The main menu component in iommi is used to create the main navigation for your app. This is primarily useful for SaaS or internal apps. It creates a sidebar menu with support for nested menu items, and centralized access control that automatically shows only menu items the user has access to.

To set up your main menu:

  • add the iommi.experimental.main_menu.main_menu_middleware middleware to the MIDDLEWARE list

  • declare your MainMenu

  • define the IOMMI_MAIN_MENU setting to point to where you have defined your menu (like IOMMI_MAIN_MENU = 'your_app.main_menu.main_menu').

  • add the url patterns from the menu to your app

Access control is recursive, meaning that if a user does not have access to a menu item, it is automatically denied access to all subitems.

Note

There are many more examples in the cookbook.

menu_declaration = MainMenu(
    items=dict(
        artists=M(
            icon='people',
            view=artists_view,
        ),
        albums=M(
            icon='disc',
            view=albums_view,
        ),
    ),
)

Add the url patterns from the menu to your app:

urlpatterns = menu_declaration.urlpatterns()

Your views will now get the menu rendered on standard iommi views. For non-iommi views you can render the menu with {{ request.iommi_main_menu }}.

▼ Hide result
Next
Pages
Previous
Fragments
Copyright © 2025, Anders Hovmöller & Johan Lübcke
Made with Sphinx and @pradyunsg's Furo