Setting object to Django cache API fails due to sort error

I am trying to manually set an object in the Django cache API, but it doesnโ€™t work (I think it is due to etching?) The object is provided to me by a third party, my code is:

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))

      

When I run this, I get an error:

Can't pickle <type 'etree._Element'>: import of module etree failed
in -    cache.set("user_list_ds", user_list, 10*60) # 10 minutes 

      

I'm very new to python and I'm wondering what is the best way to solve this, I need to expand on something?

+2


source to share


1 answer


It looks like you need to install ElementTree

because the operation is pickle

trying and unable to import the module etree

.



UPDATE: if you look at it, are you trying to cache document nodes? If you are trying to cache data from a node, you will probably need to do some processing on the value you are currently storing in user_list

.

+2


source







All Articles