skip to navigation
skip to content

webstack-django-sorting 0.4

Easy sorting of tables with Django

Latest Version: 0.4.2

webstack-django-sorting allows for easy sorting, and sorting links generation without modifying your views. It is the perfect companion of linaro-django-pagination”,

There are really 5 steps to setting it up with your projects.

  1. List this application in the INSTALLED_APPS portion of your settings file. Your settings file might look something like:

        # ...
  2. Install the sorting middleware. Your settings file might look something like:

        # ...
  3. If it’s not already added in your setup, add the ‘request’ context processor:


    This example comes from Django 1.6, take care to check against your Django version which context processors are supported (see file of your Django installation).

  4. Add this line at the top of your template to load the sorting tags:

    {% load sorting_tags %}
  5. Decide on a variable that you would like to sort, and use the autosort tag on that variable before iterating over it:

    {% autosort object_list %}
  6. Now, you want to display different headers with links to sort your objects_list:

        <th>{% anchor first_name _("Name") %}</th>
        <th>{% anchor creation_date _("Creation") %}</th>

    The first argument is a field or an attribute of the objects list, and the second one (optional) is a title that would be displayed. The previous snippet will be rendered like this in French:

        <th><a href="/path/to/your/view/?sort=first_name" title="Nom">Nom</a></th>
        <th><a href="/path/to/your/view/?sort=creation_date" title="Création">Création</a></th>

    If your application doesn’t support internationalization, you can use a simple {% anchor first_name Name %}.

That’s it!

File Type Py Version Uploaded on Size
webstack-django-sorting-0.4.tar.gz (md5) Source 2014-01-09 5KB
  • Downloads (All Versions):
  • 15 downloads in the last day
  • 77 downloads in the last week
  • 368 downloads in the last month