Skip to content

Commit

Permalink
Fixes request.QUERY_PARAMS raising AttributeError since RestFramework…
Browse files Browse the repository at this point in the history
… 3.2.
  • Loading branch information
lauxley committed Dec 1, 2015
1 parent 62fab53 commit 2d25da2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions django_elasticsearch/contrib/restframework/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ class AutoCompletionMixin(ListModelMixin):

@list_route()
def autocomplete(self, request, **kwargs):
field_name = request.QUERY_PARAMS.get('f', None)
query = request.QUERY_PARAMS.get('q', '')
try:
qp = request.query_params
except AttributeError:
# restframework 2
qp = request.QUERY_PARAMS

field_name = qp.get('f', None)
query = qp.get('q', '')

try:
data = self.model.es.complete(field_name, query)
Expand Down

0 comments on commit 2d25da2

Please sign in to comment.