Skip to main content

Build Status Coverage Status

django-sortable-listview

An extension of django's ListView that provides sorting.

Features:

  • Works with django's built in pagination.
  • Contains templates & css for pagination and sort buttons (or just use the context_data and build your own).
  • Adds an arrow to show the sort direction on the active sort.
  • Knows what the next sort is (i.e. if you're already sorted by title in one direction, clicking on the title button/link again will sort it in the other direction).
  • Lets you specify default sort for your list (defaults to -id) and for each of the sortable fields.
  • Modifies the queryset, so your database does your sorting.
  • Maintains additional query strings (configurable)

Requirements

These are the supported versions. Older versions may also work.

* Python (2.7, 3.5, 3.6, 3.7)
* Django (1.11, 2.1, 2.2)

Install

Using pip::

pip install django-sortable-listview

If you want to use the provided templates and CSS add 'sortable_listview' to your INSTALLED_APPS in your django settings.

To see how to include the css and templates in your application, look at the example project. The css is just standard bootstrap.

Example Project

Screenshot of example project

To run the example project. First make sure django and django-sortable-listview are on your python path. For example, from inside a virtualenv::

pip install django
pip install django-sortable-listview

Then from your cloned folder::

cd example_project
python manage.py migrate
python manage.py runserver

You should be able to see the example project at localhost:8000. A database is provided with some sample content. The username and password is admin/admin

Development and Tests

For your development setup::

pip install -r requirements-dev.txt

To run the tests::

tox

You may not want to run the whole tox suite when you are doing development. In this case, uncomment the extra lines in requirements-dev.txt, but please don't commit these changes. (Suggestions welcome on a better way to manage this)

Change Log

0.43

  • Fix for Python 3 regression for params to remove (thanks @bw-aus, @ghost, @birdsarah)
  • Update tox to use Django 2.2 (thanks @birdsarah)

0.42

  • Fix for Django 1.11
  • Fix encoding problem (thanks @bw-aus)
  • Add CSS classes to template (thanks @JanMalte)
  • Fix missing translation (thanks @JanMalte and @valentjedi)
  • Preserve ordering of allowed sort fields (thanks @tooreht)

0.41

  • Further querystring improvement (thanks @fle)
  • Test against Django 1.8

0.40

  • Add support for Python 3
  • Add tox & travis to test all variations
  • Update license to MIT

0.30

  • Add support for preserving other query strings (thanks @fle)
  • Make sure tests run in 1.6 and 1.7 (thanks @fle)

Release files for django-sortable-listview 0.43

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-sortable-listview 0.43
File Size Uploaded
django-sortable-listview-0.43.tar.gz 18.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-sortable-listview 0.43
File Interpreter ABI Platform
django_sortable_listview-0.43-py2-none-any.whl Python 2 none any Details

Total release size: 38.2 kB

Release files / django-sortable-listview-0.43.tar.gz

Download URL django-sortable-listview-0.43.tar.gz
Size 18.9 kB
Tags Source
SHA-256 checksum
How to use checksums
679182dea6f6efeaa597ed807b061e247e0dac5d073740ab51799974655cfefa
BLAKE2b-256 checksum
How to use checksums
be210ae6305ec625a5ad0a205b29b9ef9e0d009ee942fd762ba75c2e1daad9c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/2.7.17

Release files / django_sortable_listview-0.43-py2-none-any.whl

Download URL django_sortable_listview-0.43-py2-none-any.whl
Size 19.2 kB
Tags Python 2
SHA-256 checksum
How to use checksums
4b3759a79e66086094b7f6ec79cae7b09b074644887d0a103a58456a527d1fd6
BLAKE2b-256 checksum
How to use checksums
461f7c62f9bc5606998fc16eb4c91cf40b608798f86bfe62cd1f72c729ce1314
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/2.7.17

Release history Release notifications | RSS feed

This release

0.43 This release

2 release files

0.42

1 release file

0.41

1 release file

0.40

1 release file

0.30

1 release file

0.23

1 release file

0.22

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page