An extension of django's ListView that provides sorting
An extension of django's ListView that provides sorting.
- 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)
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)
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.
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::
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)
- Fix for Python 3 regression for params to remove (thanks @bw-aus, @ghost, @birdsarah)
- Update tox to use Django 2.2 (thanks @birdsarah)
- 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)
- Further querystring improvement (thanks @fle)
- Test against Django 1.8
- Add support for Python 3
- Add tox & travis to test all variations
- Update license to MIT
- Add support for preserving other query strings (thanks @fle)
- Make sure tests run in 1.6 and 1.7 (thanks @fle)
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size django_sortable_listview-0.43-py2-none-any.whl (19.2 kB)||File type Wheel||Python version py2||Upload date||Hashes View|
|Filename, size django-sortable-listview-0.43.tar.gz (18.9 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for django_sortable_listview-0.43-py2-none-any.whl
Hashes for django-sortable-listview-0.43.tar.gz