我在尝试设置对象列表时遇到以下错误。以前我的数据不是这样的,但现在是这样了
有没有更好的方法来编写obj_list_dictize
方法来处理这类问题
谢谢
Module ckan.lib.dictization:79 in obj_list_dictize
>> obj, capacity = obj
ValueError: too many values to unpack
def obj_list_dictize(obj_list, context, sort_key=lambda x:x):
'''Get a list of model object and represent it as a list of dicts'''
result_list = []
active = context.get('active', True)
for obj in obj_list:
if context.get('with_capacity'):
obj, capacity = obj
dictized = table_dictize(obj, context, capacity=capacity)
else:
dictized = table_dictize(obj, context)
if active and obj.state != 'active':
continue
result_list.append(dictized)
return sorted(result_list, key=sort_key)
目前没有回答
相关问题 更多 >
编程相关推荐