【发布时间】:2017-05-04 23:30:02
【问题描述】:
我收到此错误
json_response_message() got multiple values for keyword argument 'response'
我知道我是怎么得到这个错误的,但是我找不到解决方法,有没有人能帮我一把?
这个错误的原因是因为这一行
return json_response_message(success_response(), response=response)
这是我创建的两个函数,但它们工作正常,
def json_response_message(response, **kwargs):
data = {}
print(response)
print(kwargs)
data.update(response)
data.update(kwargs)
return JsonResponse(data)
def success_response(*args):
# initial message to ok
message = 'OK'
# if there is *args then add this to the message
if args:
for value in args:
message += value
return {
'status': True,
'code': 200,
'message': message
}
我想如果我做这样的事情,一切都会好起来的
return json_response_message(success_response(), change_this=response)
是因为response 是保留字还是什么?无论哪种方式,有没有办法我仍然可以让它碰巧是 response=response ?因为前端的所有结构都已经设置好了。只要我有一些解决方法,我真的不想改变任何东西。
有人可以帮帮我吗?提前致谢
【问题讨论】:
-
已经问了这么多问题,您现在应该知道应该包含完整的堆栈跟踪。
标签: python django arguments response keyword