Skip to content
Like ericflo's django pagination, but this one does the sorting! used with ericflo's pagination, displaying tabular paginated and sortable data is very easy!
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
django_sorting Handle quoted strings (for multi-word titles) Apr 14, 2009
.gitignore Initial import Mar 21, 2009
CONTRIBUTORS.txt Added a contributors file. Thanks Eric :) Apr 13, 2009
LICENSE.txt Minor fixes to and added a manifest template Aug 19, 2009
README.txt Fixed issue 1. README.txt Apr 25, 2009


How to use django-sorting

``django-sorting`` allows for easy sorting, and sorting links generation 
without modifying your views.

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
           # ...

3. If it's not already added in your setup, add the request context processor.
   Note that context processors are set by default implicitly, so to set them
   explicitly, you need to copy and paste this code into your under

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 of the objects list, and the second 
    one(optional) is a title that would be displayed. The previous 
    snippet will be rendered like this:

        <th><a href="/path/to/your/view/?sort=first_name" title="Name">Name</a></th>
        <th><a href="/path/to/your/view/?sort=creation_date" title="Name">Creation</a></th>

That's it!  

You can’t perform that action at this time.