Memcache状态不适用于Django 1.11和Python 3.6

时间:2017-10-15 12:25:20

标签: python django memcached

我为我的django项目安装了memcached(Django 1.11和Python 3.6)。 当我在settings.py中将memcached_status添加到我安装的应用程序时,当我尝试打开Django管理页面时出现此错误:

Internal Server Error: /admin/
Traceback (most recent call last):
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/core/handlers/base.py", line 217, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/core/handlers/base.py", line 215, in _get_response
response = response.render()
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/response.py", line 107, in render
self.content = self.rendered_content
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/response.py", line 84, in rendered_content
content = template.render(context, self._request)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/backends/django.py", line 66, in render
return self.template.render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 207, in render
return self._render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 199, in _render
return self.nodelist.render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 990, in render
bit = node.render_annotated(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 957, in render_annotated
return self.render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/loader_tags.py", line 177, in render
return compiled_parent._render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 199, in _render
return self.nodelist.render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 990, in render
bit = node.render_annotated(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 957, in render_annotated
return self.render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/loader_tags.py", line 177, in render
return compiled_parent._render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 199, in _render
return self.nodelist.render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 990, in render
bit = node.render_annotated(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 957, in render_annotated
return self.render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/loader_tags.py", line 177, in render
return compiled_parent._render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 199, in _render
return self.nodelist.render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 990, in render
bit = node.render_annotated(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 957, in render_annotated
return self.render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/loader_tags.py", line 72, in render
result = block.nodelist.render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 990, in render
bit = node.render_annotated(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 957, in render_annotated
return self.render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/defaulttags.py", line 322, in render
return nodelist.render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 990, in render
bit = node.render_annotated(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 957, in render_annotated
return self.render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/defaulttags.py", line 216, in render
nodelist.append(node.render_annotated(context))
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 957, in render_annotated
return self.render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/defaulttags.py", line 216, in render
nodelist.append(node.render_annotated(context))
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 957, in render_annotated
return self.render(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 1040, in render
output = self.filter_expression.resolve(context)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/django/template/base.py", line 736, in resolve
new_obj = func(obj, *arg_vals)
File "/Users/comp/Desktop/Dev/educa/lib/python3.6/site-
packages/memcache_status/templatetags/memcache_status_tags.py", line 
106, in prettyname
return ' '.join([word.capitalize() for word in name.split('_')])
TypeError: a bytes-like object is required, not 'str'

在他们的github回购中,他们说我只需要在settings.py中为我已安装的应用添加memchache_status,它就可以了。 有没有人有同样的问题?如果是,我应该如何正确安装我的Django管理页面的记忆状态。

1 个答案:

答案 0 :(得分:2)

<强>更新

我怀疑您还安装了python3-memcached(现已弃用,请参阅自述文件),在这种情况下可能会覆盖您的python-memcached安装(现在支持Python 2&amp; 3)。如果是这样,您需要删除python3-memcachedpython-memcached,然后重新安装后者,版本&gt; = 1.58。

您需要将python-memcache升级到最新版本,目前为1.58。

此包与您的memcached服务器交互以提取其收集的统计信息。早期版本的软件包没有将传入的统计数据(特别是密钥)解码为Python 3 str类型(即unicode),只是将bytes字符串传递给memcached_status prettyname过滤器 - 假定str对象。