menu_item.rst 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ======================================
  2. Customising the menu item
  3. ======================================
  4. You can use the following attributes and methods on the ``ModelAdmin`` class to
  5. alter the menu item used to represent your model in Wagtail's admin area.
  6. .. contents::
  7. :local:
  8. :depth: 1
  9. .. _modeladmin_menu_label:
  10. -------------------------
  11. ``ModelAdmin.menu_label``
  12. -------------------------
  13. **Expected value**: A string.
  14. Set this attribute to a string value to override the label used for the menu
  15. item that appears in Wagtail's sidebar. If not set, the menu item will use
  16. ``verbose_name_plural`` from your model's ``Meta`` data.
  17. .. _modeladmin_menu_icon:
  18. -------------------------
  19. ``ModelAdmin.menu_icon``
  20. -------------------------
  21. **Expected value**: A string matching one of Wagtail's icon class names.
  22. If you want to change the icon used to represent your model, you can set the
  23. ``menu_icon`` attribute on your class to use one of the other icons available
  24. in Wagtail's CMS. The same icon will be used for the menu item in Wagtail's
  25. sidebar, and will also appear in the header on the list page and other views
  26. for your model. If not set, ``'doc-full-inverse'`` will be used for
  27. page-type models, and ``'snippet'`` for others.
  28. If you're using a ``ModelAdminGroup`` class to group together several
  29. ``ModelAdmin`` classes in their own sub-menu, and want to change the menu item
  30. used to represent the group, you should override the ``menu_icon`` attribute on
  31. your ``ModelAdminGroup`` class (``'folder-open-inverse'`` is the default).
  32. .. _modeladmin_menu_order:
  33. -------------------------
  34. ``ModelAdmin.menu_order``
  35. -------------------------
  36. **Expected value**: An integer between ``1`` and ``999``.
  37. If you want to change the position of the menu item for your model (or group of
  38. models) in Wagtail's sidebar, you do that by setting ``menu_order``. The value
  39. should be an integer between ``1`` and ``999``. The lower the value, the higher
  40. up the menu item will appear.
  41. Wagtail's 'Explorer' menu item has an order value of ``100``, so supply a value
  42. greater than that if you wish to keep the explorer menu item at the top.
  43. .. _modeladmin_add_to_settings_menu:
  44. -----------------------------------
  45. ``ModelAdmin.add_to_settings_menu``
  46. -----------------------------------
  47. **Expected value**: ``True`` or ``False``
  48. If you'd like the menu item for your model to appear in Wagtail's 'Settings'
  49. sub-menu instead of at the top level, add ``add_to_settings_menu = True`` to
  50. your ``ModelAdmin`` class.
  51. This will only work for individual ``ModelAdmin`` classes registered with their
  52. own ``modeladmin_register`` call. It won't work for members of a
  53. ``ModelAdminGroup``.