问题现象
lUsers从User表中获取出来,与lUser.id进行对比
报错
AttributeError at /ClassUser/
'dict' object has no attribute 'id'
查看User变量,已经序列化处理
user
{'City': u'u77f3u5bb6u5e84', 'CreateTime': datetime.datetime(2015, 12, 12, 11, 59, 32), 'IsDelete': False, 'ModifyTime': datetime.datetime(2016, 5, 18, 10, 8, 20), 'Nick': u'u4ecau5929u661fu671f5', 'PhoneNumber': u'18584050213', 'Provence': u'u6cb3u5317', 'Role': u'u7ba1u7406u5458', 'Sex': u'u7537', 'UserName': u'yinshunyao119', '_FILE_HeaderFigure': u'_User_2XbNIvwVEayfsfhC20160513_223856', 'country': u'u4e2du56fd', 'hxUserName': u'm18584050213', 'id': 4L}
lUser变量,看出lUser还是User对象
lUser <User: xxx>
解决办法
将if user.id == lUser.id: 修改成
if user[‘id’] == lUser.id: