python queryset_Django之querySet如何解析使用

django中为了获取某一列数据库的值,比如获取某个用户的密码:

pswd = user.filter(name__exact=name).values('password')

执行之后返回的结果是:

希望把value(123456)解析出来

使用了model_to_dict方法,

pswd = user.filter(name__exact=name).values('password')

pswd = model_to_dict(user)

会报错:

Traceback (most recent call last):

File "C:\Python27\lib\site-packages\django\core\handlers\exception.py", line 41, in inner

response = get_response(request)

File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 187, in _get_response

response = self.process_exception_by_middleware(e, request)

File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 185, in _get_response

response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "E:\personal\study\Python\projects\django_demo\booktest\views.py", line 110, in userLoginSubmit

pswd = model_to_dict(user,pswd)

File "C:\Python27\lib\site-packages\django\forms\models.py", line 87, in model_to_dict

opts = instance._meta

AttributeError: 'UserInfoManager' object has no attribute '_meta'

求各位大神指导!!!

你可能感兴趣的:(python,queryset)