解决 InvalidCacheBackendError: Could not find backend
报错如下:
token = cache.get('token')
File "/usr/lib/python2.7/site-packages/Django-1.11.5-py2.7.egg/django/core/cache/__init__.py", line 99, in __getattr__
return getattr(caches[DEFAULT_CACHE_ALIAS], name)
File "/usr/lib/python2.7/site-packages/Django-1.11.5-py2.7.egg/django/core/cache/__init__.py", line 80, in __getitem__
cache = _create_cache(alias)
File "/usr/lib/python2.7/site-packages/Django-1.11.5-py2.7.egg/django/core/cache/__init__.py", line 54, in _create_cache
"Could not find backend '%s': %s" % (backend, e))
InvalidCacheBackendError: Could not find backend 'django_redis.cache.RedisCache': cannot import name get_cache
当我看到这个报错的时候,想到的问题就是包的问题,那么就是包的版本有问题了
django-redis==3.8.3
这是我使用的包版本,问题就出现在这个上,我换成
django-redis==4.10.0
再执行相同的代码,就过了,也不知道3.8.3的版本做了什么操作。
还没有评论,来说两句吧...