我已按照以下文档中的定义设置了缓存:
CACHES = {
'default': {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': [
'redis://127.0.0.1:6379',
],
'TIMEOUT': None,
}
}
现在我尝试在我的网站上访问它并收到此错误:
ConnectionError at /exchange/provider
Error 10061 connecting to 127.0.0.1:6379. No connection could be made because the target machine actively refused it.
Request Method: GET
Request URL: http://127.0.0.1:8000/exchange/provider
Django Version: 2.0.2
Exception Type: ConnectionError
Exception Value:
Error 10061 connecting to 127.0.0.1:6379. No connection could be made because the target machine actively refused it.
Exception Location: C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\redis\connection.py in connect, line 489
Python Executable: C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\python.exe
Python Version: 3.6.4
Python Path:
['C:\\Users\\sdres\\Documents\\Django\\github_repo\\32018\\innovatorsedge',
'C:\\Program Files (x86)\\Microsoft Visual '
'Studio\\Shared\\Python36_64\\python36.zip',
'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64\\DLLs',
'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64\\lib',
'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64',
'C:\\Program Files (x86)\\Microsoft Visual '
'Studio\\Shared\\Python36_64\\lib\\site-packages',
'C:\\Users\\sdres\\Documents\\Django\\github_repo\\32018\\innovatorsedge']
Server time: Thu, 22 Mar 2018 18:16:13 -0700
Error during template rendering
In template C:\Users\sdres\Documents\Django\github_repo\32018\innovatorsedge\common\templates\common\base.html, error at line 0
Error 10061 connecting to 127.0.0.1:6379. No connection could be made because the target machine actively refused it.
1 {% include "common/header.html" %}
2 {% block content %}{% endblock %}
3 {% include "common/footer.html" %}
Traceback Switch to copy-and-paste view
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django_redis\cache.py in _decorator
return method(self, *args, **kwargs) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django_redis\cache.py in get
client=client) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django_redis\client\default.py in get
raise ConnectionInterrupted(connection=client, parent=e) ...
▶ Local vars
During handling of the above exception (Redis ConnectionError: Error 10061 connecting to 127.0.0.1:6379. No connection could be made because the target machine actively refused it.), another exception occurred:
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\core\handlers\exception.py in inner
response = get_response(request) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\core\handlers\base.py in _get_response
response = self.process_exception_by_middleware(e, request) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\core\handlers\base.py in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\contrib\auth\decorators.py in _wrapped_view
return view_func(request, *args, **kwargs) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\views\decorators\cache.py in _wrapped_view_func
response = view_func(request, *args, **kwargs) ...
▶ Local vars
C:\Users\sdres\Documents\Django\github_repo\32018\innovatorsedge\matching\views.py in provider_dashboard_view
return render(request, 'matching/provider-dashboard.html', context) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\shortcuts.py in render
content = loader.render_to_string(template_name, context, request, using=using) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\template\loader.py in render_to_string
return template.render(context, request) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\template\backends\django.py in render
return self.template.render(context) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\template\base.py in render
return self._render(context) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\template\base.py in _render
return self.nodelist.render(context) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\template\base.py in render
bit = node.render_annotated(context) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\template\base.py in render_annotated
return self.render(context) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\template\loader_tags.py in render
return compiled_parent._render(context) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\template\base.py in _render
return self.nodelist.render(context) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\template\base.py in render
bit = node.render_annotated(context) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\template\base.py in render_annotated
return self.render(context) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\template\loader_tags.py in render
result = block.nodelist.render(context) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\template\base.py in render
bit = node.render_annotated(context) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\template\base.py in render_annotated
return self.render(context) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django\templatetags\cache.py in render
value = fragment_cache.get(cache_key) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django_redis\cache.py in _decorator
raise e.parent ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\django_redis\client\default.py in get
value = client.get(key) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\redis\client.py in get
return self.execute_command('GET', name) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\redis\client.py in execute_command
connection.send_command(*args) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\redis\connection.py in send_command
self.send_packed_command(self.pack_command(*args)) ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\redis\connection.py in send_packed_command
self.connect() ...
▶ Local vars
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\redis\connection.py in connect
raise ConnectionError(self._error_message(e))
我无法弄清楚我做错了什么,我能够正常访问我的普通8000插槽并连接到我的数据库,但是只要我导航到一个页面&& #39;使用缓存我收到此错误。请大家帮忙,大多数其他文档都会讨论电子邮件,我找到的唯一一个与django缓存有关的文件没有得到解答。
谢谢,
答案 0 :(得分:0)
我意识到我使用的是较旧版本的redis。我升级到3.2,现在工作正常。