开发者

How come I can't get Django to talk to this library?

I want to use Redis. So I followed this tutorial: https://github.com/sebleier/django-redis-cache

First, I install redis-py: https://github.com/andymccurdy/redis-py/

Then, I put this in my settings: CACHE_BACKEND = 'redis_cache.cache://localhost:6379'

Then I do this in my views.py:

from redis_c开发者_如何学Pythonache import cache #this imports just fine!
cache.set("haha","lala")
print cache.get("haha")

But for some reason, I get an AttributeError:

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


You want to import Django's cache module (the abstraction layer that calls Redis eventually) instead of directly using Redis:

from django.core.cache import cache
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜