Skip to content

Commit a57d4e3

Browse files
committed
Fix deprecated use of REQUEST and only read the GET request
RemovedInDjango19Warning: `request.REQUEST` is deprecated, use `request.GET` or `request.POST` instead.
1 parent 8315c78 commit a57d4e3

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

webstack_django_sorting/middleware.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
def get_field(self):
22
try:
3-
field = self.REQUEST['sort']
3+
field = self.GET['sort']
44
except (KeyError, ValueError, TypeError):
55
field = ''
66
return (self.direction == 'desc' and '-' or '') + field
77

88
def get_direction(self):
99
try:
10-
return self.REQUEST['dir']
10+
return self.GET['dir']
1111
except (KeyError, ValueError, TypeError):
1212
return 'desc'
1313

1414

1515
class SortingMiddleware(object):
1616
"""
17-
Inserts a variable representing the field (with direction of sorting)
18-
onto the request object if it exists in either **GET** or **POST**
19-
portions of the request.
17+
Inserts a variable representing the field (with direction of sorting) onto
18+
the request object if it exists in **GET** portions of the request.
2019
"""
2120
def process_request(self, request):
2221
request.__class__.field = property(get_field)

0 commit comments

Comments
 (0)