autocomplete also needs nulls_last

This commit is contained in:
j 2011-01-25 20:53:21 +05:30
parent 9aa0c7bec7
commit f7c202ce58

View file

@ -281,7 +281,7 @@ def autocomplete(request):
qs = qs.filter(find__key=data['key'], find__value__istartswith=data['value']) qs = qs.filter(find__key=data['key'], find__value__istartswith=data['value'])
elif op == '$': elif op == '$':
qs = qs.filter(find__key=data['key'], find__value__iendswith=data['value']) qs = qs.filter(find__key=data['key'], find__value__iendswith=data['value'])
qs = qs.order_by(order_by) qs = qs.order_by(order_by, nulls_last=True)
qs = qs[data['range'][0]:data['range'][1]] qs = qs[data['range'][0]:data['range'][1]]
response = json_response({}) response = json_response({})
response['data']['items'] = [i.get(data['key']) for i in qs] response['data']['items'] = [i.get(data['key']) for i in qs]