Skip to content

Commit

Permalink
REQUEST deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichal authored Apr 20, 2017
1 parent ac1021b commit 7450fe2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions django_sorting/middleware.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
def get_field(self):
ordering = []
try:
field = self.REQUEST['sort']
# REQUEST is deprecated as of Django 1.7.
field = self.POST.get('sort')
if field is None:
field = self.GET.get('sort')
except (KeyError, ValueError, TypeError):
pass
else:
Expand All @@ -12,7 +15,11 @@ def get_field(self):

def get_direction(self):
try:
return self.REQUEST['dir']
# REQUEST is deprecated as of Django 1.7.
value = self.POST.get('dir')
if value is None:
value = self.GET.get('dir')
return value
except (KeyError, ValueError, TypeError):
return 'desc'

Expand Down

0 comments on commit 7450fe2

Please sign in to comment.