标签:for rate dict rom djang ack return self views
from haystack.views import SearchView
from django.http import JsonResponse
class MysearchView(SearchView):
def create_response(self):
"""
Generates the actual HttpResponse to send back to the user.
"""
context = self.get_context()
data_list=[]
data_dict={}
for i in context[‘page‘].object_list:
data_dict[‘id‘]=i.object.id
data_dict[‘name‘]=i.object.name
data_dict[‘content‘] = i.object.content
data_list.append(data_dict)
# print(context[‘page‘].object_list)
#
return JsonResponse(data_list,safe=False,json_dumps_params={‘ensure_ascii‘:False})
url
url(r‘^search/‘, search.MysearchView()),
标签:for rate dict rom djang ack return self views
原文地址:https://www.cnblogs.com/wrqysrt/p/10776789.html