Admin Tabs in change formΒΆ

A templatetag to create a tabbed layout in a change_form. It looks in ModelAdmin for method ‘get_tabs’. The default get_tabs is as follows:

def get_tabs(self, request, obj):
   return self.tabs

that means you can just set tabs in you ModelAdmin. Tabs is a tuple of tuples. An example of a hypothetical Author model whose Inlines are BookInline and ArticleInline:

tabs = (
  (_('Author'), {'items': [_('general_info')]}),
  (_('Books/Articles'), {'items': [BookModel, ArticleModel], 'active': True),
)

Resulting in 2 tabs with label ‘Author’ and ‘Book/Articles’ Each element of tabs is a tuple composed of:

  • a label

  • a list of elements (possibly empty). Each element can be eather a string that will be interpreted as the name of a fieldset declared in fieldsets or a model, whose inline must be declared in the standard way. You can also leave an empty list: the first one that is left as an empty list will be filled with all fieldsets as in:

    (_('Author'), {}),
    

This grants the ability to place all peaces in any fancy way

Previous topic

Search_form

Next topic

Dashboard

This Page