2011-01-08 95 views
0

我想使用Redis。所以我跟着这个教程:https://github.com/sebleier/django-redis-cache我怎么不能让Django与这个图书馆交谈?

首先,我安装的Redis-PY:https://github.com/andymccurdy/redis-py/

然后,我把这个在我的设置:CACHE_BACKEND = 'redis_cache.cache://localhost:6379'

然后,我做这在我的views.py:

from redis_cache import cache #this imports just fine! 
cache.set("haha","lala") 
print cache.get("haha") 

但由于某些原因,我得到一个AttributeError:

Exception Type: AttributeError at/
Exception Value: 'module' object has no attribute 'set' 

回答

1

您想要导入Django的缓存模块(最终调用Redis的抽象层)而不是直接使用Redis:

from django.core.cache import cache