断然的
我正在尝试用django框架学习redis。我的程序是打算计算图像视图,但当我点击图像的细节,它给了我上述的错误。我无法与redis建立连接。这是我的细节错误的链接http://dpaste.com/1taj4mf
我已经在windows10上安装并运行了redis cli,下面是我的settings.py代码
# Configuring Redis database
REDIS_HOST = 'localhost'
REDIS_PORT = 6397
REDIS_DB = 0
视图.py
import redis
from django.conf import settings
def detail(request, id):
profile = get_object_or_404(Profile, id=id)
# increment total image views by 1
total_views = r.incr('profile:{}:views'.format(profile.id))
return render(request, 'images/detail.html', {'profile': profile, 'total_views': total_views})
详细信息.html
<body>
<img src="{{ profile.photo.url }}" width="500" height="500" alt="Image not found">
<br>
{{ profile.user.username.title }}.
{{ profile.dob }}
<br>
{{ total_views }} view{{ total_views|pluralize }}
</body>
暂无答案!
目前还没有任何答案,快来回答吧!