Candy translate 将从 controllers.py 返回的数据转换为 javascript?

问题描述 投票:0回答:0

def mymethod(request):
    return_obj = {}
    if request.method == 'POST':
        info = request.POST
    try:
        ts_vals, coordinates, name = somefunction(params)
        return_obj["values"] = ts_vals
        return_obj["msg"] = candy.translated(request, "all_msg") # all_msg is from the excel

        return_obj["name"] = name
        return_obj["success"] = "success"
    except Exception as e:
        return_obj["error"] = candy.translated(request, "all_Error")
    return JsonResponse(return_obj)


我试过上面的过程。返回的 JSON 在我的 javascript 代码中解析并从 javascript 代码发送回接口。我们如何使用 Candy Translation 处理这种情况?

python django translation candy
© www.soinside.com 2019 - 2024. All rights reserved.