apply_query shouldn't modify the parameters dictionary

Changing parameters in apply_query might yield an invalid state in later
code that assumes the query was not changed.
This patch avoids parameters modification and should fix the issue
reported in #109
This commit is contained in:
Ivan Giuliani 2012-01-18 14:39:36 +01:00
parent 119b951086
commit b6472507e4

View File

@ -173,10 +173,12 @@ def apply_query(queryset, params):
# eg a Q() set # eg a Q() set
queryset = queryset.filter(params['other_filter']) queryset = queryset.filter(params['other_filter'])
if params.get('sorting', None): sorting = params.get('sorting', None)
if params.get('sortreverse', None): if not sorting:
params['sorting'] = "-%s" % params['sorting'] sortreverse = params.get('sortreverse', None)
queryset = queryset.order_by(params['sorting']) if not sortreverse:
sorting = "-%s" % sorting
queryset = queryset.order_by(sorting)
return queryset return queryset