@@ -4,10 +4,10 @@ webstack-django-sorting
44What?
55-----
66
7- `` webstack-django-sorting ` ` is a Django app which allows for easy sorting of
7+ ` webstack-django-sorting ` is a Django app which allows for easy sorting of
88data tables. You don't need to change anything to your views to use it. It
99provides sorting links for table headers. It is the perfect companion of
10- ` django-pagination < https://github.com/zyga/django-pagination >`_ .
10+ [ django-pagination] ( https://github.com/zyga/django-pagination ) .
1111
1212A demonstration of the features is provided in ` testproj ` directory.
1313
@@ -18,29 +18,32 @@ Features
1818- Switches between ascending, descending, and no sorting
1919- Provides links to sort on different criterions
2020- Visual feedback on applied ordering
21- - Supports Python 2.7, 3.5 and 3.6
21+ - Supports Python 2.7, 3.5+
2222- Supports translation of link titles
2323
24- Upgrade from v0.5.0 and below
25- -----------------------------
24+ Upgrade from v0.5.0
25+ -------------------
2626
27- To upgrade to `` webstack-django-sorting ` ` v1.0.0+, you must remove the old middleware
28- `` webstack_django_sorting.middleware.SortingMiddleware `` from `` MIDDLEWARE_CLASSES ` ` list.
27+ To upgrade to ` webstack-django-sorting ` v1.0.0+, you must remove the old middleware
28+ ` webstack_django_sorting.middleware.SortingMiddleware ` from ` MIDDLEWARE_CLASSES ` list.
2929
3030How to use it in your project
3131---------------------------------
3232
33- 1. `` pip install webstack_django_sorting ` `
33+ 1 . ` pip install webstack_django_sorting `
3434
35- 2. Add the application to the `` INSTALLED_APPS `` list: :
35+ 2 . Add the application to the ` INSTALLED_APPS ` list:
3636
37+ ``` python
3738 INSTALLED_APPS = [
3839 # ...
3940 ' webstack_django_sorting' ,
4041 ]
42+ ```
4143
42- 3. Check the request context processor is loaded in `` TEMPLATES `` options: :
44+ 3 . Check the request context processor is loaded in `TEMPLATES ` options:
4345
46+ ```python
4447 TEMPLATES = [
4548 {
4649 ' BACKEND' : ' django.template.backends.django.DjangoTemplates' ,
@@ -55,34 +58,39 @@ How to use it in your project
5558 },
5659 },
5760 ]
61+ ```
5862
59- 4. Add this line at the top of your template to load the sorting tags::
63+ 4 . Add this line at the top of your template to load the sorting tags:
6064
6165 {% load sorting_tags % }
6266
63675 . Decide on a variable that you would like to sort, and use the
64- autosort tag on that variable before iterating over it::
68+ autosort tag on that variable before iterating over it:
6569
6670 {% autosort object_list % }
6771
68726 . Now, you want to display different headers with links to sort
69- your objects_list::
73+ your objects_list:
7074
75+ ```html
7176 < tr>
7277 < th> {% anchor first_name _(" Name" ) % }< / th>
7378 < th> {% anchor creation_date _(" Creation" ) % }< / th>
7479 < / tr>
80+ ```
7581
7682 The first argument is a field or an attribute of the objects list , and the
7783 second one (optional) is a title that would be displayed. The previous
78- snippet will be rendered like this in French::
84+ snippet will be rendered like this in French:
7985
86+ ```html
8087 < tr>
8188 < th>< a href= " /path/to/your/view/?sort=first_name" title= " Nom" > Nom< / a>< / th>
8289 < th>< a href= " /path/to/your/view/?sort=creation_date" title= " Création" > Création< / a>< / th>
8390 < / tr>
91+ ```
8492
8593 If your application doesn' t support internationalization, you can use a
86- simple `` {% anchor first_name Name %} ` `.
94+ simple `{% anchor first_name Name % }` .
8795
8896That' s it!
0 commit comments