如何在Django中缓存自定义模型的列表?

2024-05-29 10:36:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个模型列表,[Book1,Book2,Book3],我需要缓存。当我试图缓存它们时,我得到一个错误:cannotpickle\u Element objects 我用的是代码:

if cache.get(isbn):
    sellers = cache.get(isbn)
else:
    sellers = get_all_amazon_sellers(isbn)
    cache.set(isbn, sellers, 600)

非常感谢你!在


Tags: 代码模型cache列表getifobjects错误

热门问题