Added OrderingFilter

This commit is contained in:
Tom Christie 2013-05-14 11:27:08 +01:00
parent 6a037f63ed
commit 2cff6e69db
3 changed files with 5 additions and 5 deletions

View File

@ -216,7 +216,7 @@ For more details, see the [Django documentation][search-django-admin].
## OrderingFilter
The `OrderingFilter` class supports simple query parameter controlled ordering of results. For example:
The `OrderingFilter` class supports simple query parameter controlled ordering of results. To specify the result order, set a query parameter named `'order'` to the required field name. For example:
http://example.com/api/users?ordering=username

View File

@ -112,7 +112,7 @@ class SearchFilter(BaseFilterBackend):
class OrderingFilter(BaseFilterBackend):
ordering_param = 'order' # The URL query parameter used for the ordering.
ordering_param = 'ordering' # The URL query parameter used for the ordering.
def get_ordering(self, request):
"""

View File

@ -369,7 +369,7 @@ class OrderingFilterTests(TestCase):
ordering = ('title',)
view = OrderingListView.as_view()
request = factory.get('?order=text')
request = factory.get('?ordering=text')
response = view(request)
self.assertEqual(
response.data,
@ -387,7 +387,7 @@ class OrderingFilterTests(TestCase):
ordering = ('title',)
view = OrderingListView.as_view()
request = factory.get('?order=-text')
request = factory.get('?ordering=-text')
response = view(request)
self.assertEqual(
response.data,
@ -405,7 +405,7 @@ class OrderingFilterTests(TestCase):
ordering = ('title',)
view = OrderingListView.as_view()
request = factory.get('?order=foobar')
request = factory.get('?ordering=foobar')
response = view(request)
self.assertEqual(
response.data,