if request.path == '/sort/':
    sortid = request.POST.get('sortid')
locs = Location.objects.order_by(sortid)
if request.is_ajax():
    locs = json.dumps(locs)
return HttpResponse(locs, mimetype='application/json')
How to return json dictionary in django ajax update