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.
- Python: 3.7, 3.8, 3.9
- Django: 2.2, 3.0, 3.1, 3.2
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}
]
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.
- 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.
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.
CriteriaView lets you provide a list of functions, one per column, that VMC uses to determine which column an item will be placed in.
DefinedView lets you provide the columns you want displayed. VMC does the rest.
For more extensive document see the docs
folder or read it in readthedocs.
If you have questions about usage or development you can open an issue on GitHub. You can also contact Susan Wright directly.
- To Graham Wright for his guidance and support in publishing this.