Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
iommi unknown documentation
Logo
iommi unknown documentation

Tutorials

  • Getting started
  • Tutorial

How-to guides

  • Cookbook
    • General
    • Parts & Pages
    • Forms
    • Tables
    • Edit tables
    • Queries
    • Main menu
    • Calendar
    • Style
    • Path decoding
    • Access control
    • Admin
    • Testing
    • Production use
    • Add iommi to a FBV
    • Porting

Reference

  • API Reference
    • Action
    • Asset
    • Attrs
    • Calendar
    • Cell
    • Cells
    • Column
    • ColumnHeader
    • Container
    • EditColumn
    • EditTable
    • Endpoint
    • Field
    • Filter
    • Form
    • FormAutoConfig
    • Fragment
    • Header
    • HeaderConfig
    • M
    • MainMenu
    • Members
    • Menu
    • MenuItem
    • Page
    • Panel
    • PanelCol
    • Part
    • Query
    • QueryAutoConfig
    • Style
    • Table
    • TableAutoConfig
    • Traversable
    • Functions
    • middleware
  • 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
  • Views
  • Dev tools

Explanation

  • Components
    • Edit tables
    • Forms
    • Fragments
    • Main menu
    • Pages
    • Queries
    • Tables
  • Understanding iommi
    • Architecture
    • Equivalence
    • Philosophy
    • Registrations
    • Semantic models

About the project

  • Imports used in the iommi documentation
  • Changelog
  • Credits
  • Contributing
  • @github
  • @discord
  • @pypi
Back to top
View this page

Main menu¶

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.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
Toggle structure
Next
Pages
Previous
Fragments
Copyright © 2025, Anders Hovmöller & Johan Lübcke
Made with Sphinx and @pradyunsg's Furo