Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将列表作为函数之一传递';s的论点_Python_Django_Django Rest Framework - Fatal编程技术网

Python 将列表作为函数之一传递';s的论点

Python 将列表作为函数之一传递';s的论点,python,django,django-rest-framework,Python,Django,Django Rest Framework,我想在会话中存储登录表单中的用户名和密码,以便将来在REST请求中使用: request.session['credentials'] = (request.POST['username'],request.POST['password']) 然后,使用python请求模块(和我的自定义包装器),我希望将其作为远程连接请求的身份验证头传递: devices = client['devices/'].get(auth=request.session['credentials']) 但我得到了一

我想在会话中存储登录表单中的用户名和密码,以便将来在REST请求中使用:

request.session['credentials'] = (request.POST['username'],request.POST['password'])
然后,使用python请求模块(和我的自定义包装器),我希望将其作为远程连接请求的身份验证头传递:

devices = client['devices/'].get(auth=request.session['credentials'])
但我得到了一个错误:

“列表”对象不可调用

这就像一个符咒,当我传递类似于:
('admin','admin')


如何传递这样的参数?

看起来像是一个列表,但传递元组是有效的。试一试

tuple(request.session['credentials'])

异常的完整回溯是什么?当你打印请求时。会话['credentials']你得到什么?当我打印请求时。会话['credentials']我得到:[u'admin',u'admin']Django可以为你处理所有这些,你为什么不使用Django内置的会话存储?请看这里: