This software offers sorting functionality to Ericflo's Django pagination. It makes displaying tabular data that can be paginated and sorted a breeze when used in combination with Ericflo's pagination.
Firstly, you need to list this application in the "INSTALLED_APPS" part of your settings file. Your settings file should look similar to the following:
```
INSTALLED_APPS = (
# ...
'sorting',
)
```
Next, install the sorting middleware. Your settings file should include the following:
```
MIDDLEWARE_CLASSES = (
# ...
'sorting.middleware.SortingMiddleware',
)
```
If the request context processor hasn't already been added in your setup, you will need to add it explicitly. The context processors are usually set implicitly, but to set them explicitly, you need to copy and paste this code into your settings file below the value TEMPLATE_CONTEXT_PROCESSORS:
```
("django.core.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.request")
```
To load the sorting tags, you need to add this line at the beginning of your template:
```
{% load sorting_tags %}
```
Next, decide on a variable you would like to sort, and use the "autosort" tag on it before iterating over it. The code would look like this:
```
{% autosort object_list %}
```
Finally, if you want to display different headers with links to sort your objects_list, you will want to use the "th" tag. For example:
```
{% th first_name Name %}
{% th creation_date Creation %}
...
```
The first argument represents a field of the objects list, and the second one is the (optional) title that will be displayed. With this process complete, your headers should appear like this:
```
Name
Creation
...
```
Overall, django-sorting is an incredibly useful tool for simplifying sorting and table header generation, making it an ideal addition to any software project.
Version 0.1: N/A