解决 InvalidCacheBackendError: Could not find backend

柔光的暖阳◎ 2021-06-24 16:09 1263阅读 0赞

报错如下:

  1. token = cache.get('token')
  2. File "/usr/lib/python2.7/site-packages/Django-1.11.5-py2.7.egg/django/core/cache/__init__.py", line 99, in __getattr__
  3. return getattr(caches[DEFAULT_CACHE_ALIAS], name)
  4. File "/usr/lib/python2.7/site-packages/Django-1.11.5-py2.7.egg/django/core/cache/__init__.py", line 80, in __getitem__
  5. cache = _create_cache(alias)
  6. File "/usr/lib/python2.7/site-packages/Django-1.11.5-py2.7.egg/django/core/cache/__init__.py", line 54, in _create_cache
  7. "Could not find backend '%s': %s" % (backend, e))
  8. InvalidCacheBackendError: Could not find backend 'django_redis.cache.RedisCache': cannot import name get_cache

当我看到这个报错的时候,想到的问题就是包的问题,那么就是包的版本有问题了

  1. django-redis==3.8.3

这是我使用的包版本,问题就出现在这个上,我换成

  1. django-redis==4.10.0

再执行相同的代码,就过了,也不知道3.8.3的版本做了什么操作。

发表评论

表情:
评论列表 (有 0 条评论,1263人围观)

还没有评论,来说两句吧...

相关阅读