我正在尝试在 Django 缓存 API 中手动设置一个对象,但它失败了(我认为是因为酸洗?)该对象是由第三方提供给我的,我的代码是:
def index(request, template_name="mytemplate.htm"):
user_list = cache.get("user_list_ds")
if user_list is None:
# this is the expensive bit I'm trying to cache
# given to me by a third part
user_list = graffiti.user_list("top", 100).responseObj().blocks()
cache.set("user_list_ds", user_list, 10*60) # 10 minutes
return render_to_response(template_name, { 'user_list' : user_list,}, context_instance = RequestContext(request))
当我运行它时,我得到一个错误;
Can't pickle <type 'etree._Element'>: import of module etree failed
in - cache.set("user_list_ds", user_list, 10*60) # 10 minutes
我对python很陌生,我想知道如何最好地解决这个问题,我需要先腌制一些东西吗?