python - Implementation of ajax+djangorestframework doesn't work 500 -


i using djangorestframework in order implement ajax post request.

but unfortunately doesn't work. djangorest docs can use default serialisation , return data in way doesn't work. code correct? or way use ajax djangorestframework create own serialiser ?

@api_view(['post', ]) def live_search(request):     if request.method == 'post':         key = request.data['key']         result = event.objects.filter(title__contains=key)         result_s = serializers.serialize('json', result)         request.data['result'] = result_s     else:         error = "error"         return error     return response(request.data) 

as far it's request, know it's 500 server-side error. queryset correct

@api_view(['post', ]) def live_search(request): if request.method == 'post':     data = request.data     key = data.get('key')     result = event.objects.filter(title__contains=key)     result_s = serializers.serialize(result, many=true).data                    return response({'result': result_s}) 

yoh have declare serializers on header


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -