1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How to achieve two-level dropdown (nested categories) in Flask-Admin?

Discussão em 'Python' iniciado por Stack, Setembro 18, 2025.

  1. Stack

    Stack Membro Participativo

    I’m building an admin console using Flask-Admin and I want my models to appear under a two-level dropdown menu.

    For example, in the top menu I want a single item UI. When I hover/click it, I want a dropdown like this:

    UI
    ├── UI-Tables
    │ ├── ui_templates
    │ ├── ui_components
    │ └── ...
    ├── A-Series
    │ ├── alpha_table
    │ └── ...
    └── Other
    └── misc_table


    Right now, Flask-Admin only supports one level of categories.

    I tried doing this:

    admin.add_view(ModelView(UItemplate, session, category="UI"))
    admin.add_view(ModelView(UIcomponents, session, category="UI / UI-Tables"))


    But this just flattens everything inside the dropdown, instead of showing it in a second nested level.

    Question: Is there a way to achieve nested menus (category → subcategory → models) in Flask-Admin? Or do I need to customize the template to simulate a two-level dropdown?

    Continue reading...

Compartilhe esta Página