有趣的调试会话。在这里回答,因为它肯定会发生在其他人身上。
完整的堆栈跟踪是这样的:
File "/Users/joe/Envs/folktunefinder/lib/python2.7/site-packages/django/views/defaults.py", line 41, in server_error
return http.HttpResponseServerError(template.render(Context({})))
File "/Users/joe/Envs/folktunefinder/lib/python2.7/site-packages/django/template/base.py", line 140, in render
return self._render(context)
File "/Users/joe/Envs/folktunefinder/lib/python2.7/site-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)
File "/Users/joe/Envs/folktunefinder/lib/python2.7/site-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/Users/joe/Envs/folktunefinder/lib/python2.7/site-packages/django/template/base.py", line 844, in render_node
return node.render(context)
File "/Users/joe/Envs/folktunefinder/lib/python2.7/site-packages/django/template/loader_tags.py", line 124, in render
return compiled_parent._render(context)
File "/Users/joe/Envs/folktunefinder/lib/python2.7/site-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)
File "/Users/joe/Envs/folktunefinder/lib/python2.7/site-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/Users/joe/Envs/folktunefinder/lib/python2.7/site-packages/django/template/base.py", line 844, in render_node
return node.render(context)
File "/Users/joe/Envs/folktunefinder/lib/python2.7/site-packages/fancy_tag/__init__.py", line 101, in render
return func(*args, **kwargs)
File "/Users/joe/Envs/folktunefinder/lib/python2.7/site-packages/django_browserid/templatetags/browserid.py", line 30, in browserid_css
return context['browserid_css'](**kwargs)
File "/Users/joe/Envs/folktunefinder/lib/python2.7/site-packages/django/template/context.py", line 57, in __getitem__
raise KeyError(key)
KeyError: 'browserid_css'
重新配置日志记录后,看起来我遇到了错误:
SuspiciousOperation: Invalid HTTP_HOST header (you may need to set ALLOWED_HOSTS): localhost:8000
此ALLOWED_HOSTS设置仅适用于生产模式。Django 试图呈现此错误并以某种方式呈现包含 BrowserID 标记但没有请求上下文的模板。
因此,如果您收到此错误,请首先检查ALLOWED_HOSTS
.