django-vertical-multi-columns

Generate content for rendering in Django templates in multiple vertically-sorted side-by-side columns


Keywords
django, columns, multiple, vertical, sorted, listview
License
BSD-3-Clause
Install
pip install django-vertical-multi-columns==0.9.1

Documentation

Django-Vertical-Multi-Columns

build docs codecov pypi pyvers licence black

Django-Vertical-Multi-Columns (VMC) is a reusable Django application allowing you to easily display a list of items in vertically sorted side-by-side columns rather than in one long list. It supports all JSON data types ... string, number, boolean, object, array, and null/empty.

Comparison

Requirements

  • Python: 3.7, 3.8, 3.9
  • Django: 2.2, 3.0, 3.1

Installation

Install using pip:

pip install django-vertical-multi-columns

Add 'vertical_multi_columns' to your INSTALLED_APPS setting.

INSTALLED_APPS = [
    ...
    'vertical_multi_columns',
]

In your Django settings, you can optionally specify a default number of columns to be generated.

VERTICAL_MULTI_COLUMNS = [
        {NUMBER_OF_COLUMNS=3}
]

Why You May Need This

Displaying a long list of items in a template is quite easy.

{% for row in rows %} ... {{ row.<field> }} ... {% endfor %}

This comes at a cost for your end user though. Searching through a long list can test someone's patience if it requires a lot of scrolling or paging.

What VMC Does

  • VMC views let you generate rows that can easily be displayed in multiple side-by-side columns in your templates. The columns retain your sort order so your users can still scan the data in a natural up-and-down way. And because the items are spread across the screen, your content takes less vertical space, reducing the amount of scrolling/paging a user must do.
  • You specify the number of columns you want generated.
  • VMC views are sub-classes of ListView so all its capabilities are still available to you.

View Options

There are 3 views available.

EvenView spreads your data across the number of columns you specify, keeping the length of the columns as even as possible.

EvenView

CriteriaView lets you provide a list of functions, one per column, that VMC uses to determine which column an item will be placed in.

CriteriaView

DefinedView lets you provide the columns you want displayed. VMC does the rest.

DefinedView

Documentation

For more extensive document see the docs folder or read it in readthedocs.

Comments & Support

If you have questions about usage or development you can open an issue on GitHub. You can also contact Susan Wright directly.

Special Thanks

  • To Graham Wright for his guidance and support in publishing this.