Skip to content

Commit 6965418

Browse files
committed
Add doc about nulls_first in README and fix typo
1 parent 9386882 commit 6965418

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ The project provides examples of integration with Django and Jinja2 templates.
8080
{% autosort object_list %}
8181
```
8282

83+
You can pass the option `nulls_first=True` (or `nulls_first=False`) to
84+
explicitly define the ordering of NULL (not supported by all databases,
85+
[Indexing ASC, DESC and NULLS
86+
FIRST/LAST](https://use-the-index-luke.com/sql/sorting-grouping/order-by-asc-desc-nulls-last))
87+
8388
5. Now, you want to display different headers with links to sort
8489
your objects_list:
8590

testproj/testproj/testapp/tests.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import django.template as django_template
22
from django.template.engine import Engine
33
from django.template.response import SimpleTemplateResponse
4-
from django.urls import reverse
54
from django.test import TestCase
5+
from django.urls import reverse
66

77
from . import models
88

@@ -49,7 +49,7 @@ def setUp(self):
4949
models.SecretFile.objects.create(filename="bar.txt", order=2, size=512)
5050

5151
def test_sorting_nulls_first(self):
52-
""" Verify None sorted field_name is in firsts places when sorting in asc and desc order """
52+
"""Verify None sorted field_name is in first places when sorting in asc and desc order"""
5353

5454
models.SecretFile.objects.create(filename=None, order=3, size=512)
5555
# asc order
@@ -69,7 +69,7 @@ def test_sorting_nulls_first(self):
6969
self.assertQuerysetEqual(list(response.context["secret_files"]), values)
7070

7171
def test_sorting_nulls_last(self):
72-
""" Verify None sorted field_name is in lasts places when sorting in asc and desc order """
72+
"""Verify None sorted field_name is in last places when sorting in asc and desc order."""
7373

7474
models.SecretFile.objects.create(filename=None, order=3, size=512)
7575
# asc order
@@ -89,7 +89,7 @@ def test_sorting_nulls_last(self):
8989
self.assertQuerysetEqual(list(response.context["secret_files"]), values)
9090

9191
def test_sorting_nulls_first_and_last(self):
92-
""" Verify nulls_first and nulls_last autosort params can't be used at the same time """
92+
"""Verify nulls_first and nulls_last autosort params can't be used at the same time"""
9393

9494
engine = Engine(
9595
libraries={'sorting_tags': 'webstack_django_sorting.templatetags.sorting_tags'},
@@ -100,7 +100,7 @@ def test_sorting_nulls_first_and_last(self):
100100
{% load sorting_tags %}
101101
{% autosort secret_files nulls_first=True nulls_last=True %}
102102
""")
103-
response = SimpleTemplateResponse(
103+
SimpleTemplateResponse(
104104
template,
105105
context={'secret_files': models.SecretFile.objects.all()}
106106
)

0 commit comments

Comments
 (0)