在运行redis cli时,每次都会取消我的连接

q0qdq0h2  于 2021-06-09  发布在  Redis
关注(0)|答案(0)|浏览(162)

断然的
我正在尝试用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>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题