from django.http import JsonResponse
import pymongo
import json
from bson.json_util import dumps
myclient = pymongo.MongoClient("mongodb://localhost:27017/")
mydb = myclient["game"]
mycol = mydb["test_collection"]
def fetch_data(request):
mycol = mydb["Eugenie_Table"]
country = request.GET.get('country')
qry = {'country': country}
query = mycol.find(qry).limit(10)
data = json.loads(dumps(query))
print(data)
return data
def handle_cache(request):
from multiprocessing.pool import ThreadPool
pool = ThreadPool(processes=4)
async_result = pool.apply_async(fetch_data(request))
return_val = async_result.get()
print(return_val)
return JsonResponse({})
在这里,我将django与pymongo一起用于从mongodb数据库中获取数据。 在这里我越来越错误。 错误显示在池中。
TypeError at /
'list' object is not callable
请仔细查看