Skip to content

Alt views

deby edited this page Dec 1, 2022 · 7 revisions

↑ Parent: MagiCollection

← Previous: CuteForm

List views can have alternative views. For example, you may want to provide a condensed table of data to show stats.

Your alt view must provide:

  • verbose_name

You can provide (which will override the value provided in MagiCollection settings in List view):

  • template
  • display_style
  • display_style_table_fields
  • per_line
  • icon
  • image
  • page_size
  • show_items_names
  • show_collect_button
  • show_relevant_fields_on_ordering
  • show_item_buttons
  • show_item_buttons_as_icons
  • item_padding
  • full_width
  • col_break
  • show_view_title (will show/hide the title of the view in h1 element)
  • navbar_link_title
  • show_title
  • show_small_title

Other settings:

  • hide_in_navbar
  • hide_in_filter
  • filter_queryset
class CardCollection(MagiCollection):
    ...
    class ListView(MagiCollection.ListView):
        ...
        alt_views = MagiCollection.ListView.alt_views + [
            ('statistics', {
                'verbose_name': _('Statistics'),
                'template': 'default_item_table_view',
                'display_style': 'table',
                'display_style_table_fields': [
                    'image', 'image_trained',
                    'smile_min', 'smile_max', 'smile_trained_max',
                    'pure_min', 'pure_max', 'pure_trained_max',
                    'cool_min', 'cool_max', 'cool_trained_max',
                ],
            }),
        ]

→ Next: Item Types

I. Introduction

II. Tutorials

  1. Collections
    1. MagiModel
    2. MagiCollection
    3. MagiForm
    4. MagiFiltersForm
    5. MagiFields
  2. Single pages
  3. Configuring the navbar

III. References

IV. Utils

V. Advanced tutorials

VI. More

Clone this wiki locally