【发布时间】:2020-12-25 03:26:05
【问题描述】:
我正在尝试将 Twilio 的此 Json 响应保存到我的数据库中,但不确定如何将其解析到 Django 中的模型中。目前它只是将 Json 响应输出到终端
def validate_order_with_details(request):
try:
client = Client(twillio_account_sid, twillio_auth_token)
message = client.messages.create(
from_=twillio_from_no,
body=printer,
to=twillio_sender_mobile_no
)
if message:
return JsonResponse({"data": True, "printer": printer})
else:
return JsonResponse({"data": True, "printer": "Error! while process twilio msg."})
print("There are an error with your transaction")
except Exception as e:
return JsonResponse({"data": True, "printer": str(e)})
print("There are an error with your transaction")
else:
return JsonResponse({"data": False})
感谢任何帮助。
【问题讨论】: