获得关键字参数 'response' 的多个值 - django
got multiple values for keyword argument 'response' - django
我收到这个错误
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
?因为前端的所有结构都已经搭建好了。只要我有一些解决方法,我真的不想改变任何东西。
有人可以帮帮我吗?提前致谢
这条错误消息说明了一切:json_response_message() got multiple values for keyword argument 'response'
你的函数定义 header def json_response_message(response, **kwargs):
表示第一个(位置)参数的值将被放置到 response
变量中。然后你试图将第二个参数(关键字参数)传递给你的函数调用(json_response_message(success_response(), response=response)
),其名称对应于 response
- 它已经由 success_response()
[ 返回的值分配=16=]
我收到这个错误
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
?因为前端的所有结构都已经搭建好了。只要我有一些解决方法,我真的不想改变任何东西。
有人可以帮帮我吗?提前致谢
这条错误消息说明了一切:json_response_message() got multiple values for keyword argument 'response'
你的函数定义 header def json_response_message(response, **kwargs):
表示第一个(位置)参数的值将被放置到 response
变量中。然后你试图将第二个参数(关键字参数)传递给你的函数调用(json_response_message(success_response(), response=response)
),其名称对应于 response
- 它已经由 success_response()
[ 返回的值分配=16=]