Django错误noneType

时间:2018-01-27 14:14:34

标签: django

我不知道为什么会收到此错误。这是什么意思?

我将此站点放入虚拟机并在Web服务器平台内运行。这可能是因为网站没有直接托管吗?

[26/Jan/2018 16:28:52] "GET /static/css/custom.css HTTP/1.1" 200 7346
Traceback (most recent call last):
  File "/usr/lib/python3.4/wsgiref/handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "/usr/local/lib/python3.4/dist-packages/django/contrib/staticfiles/handlers.py", line 67, in __call__
    return super().__call__(environ, start_response)
  File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/wsgi.py", line 146, in __call__
    response = self.get_response(request)
  File "/usr/local/lib/python3.4/dist-packages/django/contrib/staticfiles/handlers.py", line 62, in get_response
    return super().get_response(request)
  File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py", line 81, in get_response
    response = self._middleware_chain(request)
TypeError: 'NoneType' object is not callable
[26/Jan/2018 16:28:52] "GET /static/css/bootstrap.min.css.map HTTP/1.1" 500 59
Traceback (most recent call last):
  File "/usr/lib/python3.4/wsgiref/handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "/usr/local/lib/python3.4/dist-packages/django/contrib/staticfiles/handlers.py", line 67, in __call__
    return super().__call__(environ, start_response)
  File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/wsgi.py", line 146, in __call__
    response = self.get_response(request)
  File "/usr/local/lib/python3.4/dist-packages/django/contrib/staticfiles/handlers.py", line 62, in get_response
    return super().get_response(request)
  File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py", line 81, in get_response
    response = self._middleware_chain(request)
TypeError: 'NoneType' object is not callable

1 个答案:

答案 0 :(得分:0)

某处,你有一个未正确设置的变量,而django正试图调用它。

您可以像这样重现错误:

>>> a = None
>>> a()
Traceback (most recent call last):
  File "main.py", line 4, in <module>
    a()
TypeError: 'NoneType' object is not callable

至于为什么它会在您的应用程序中发生,如果没有显示任何代码,这很难分辨。如果您不确定错误的位置,我建议您尝试撤消最近的更改,直到它再次开始工作。

在黑暗中快速刺杀是您的某些中间件未正确配置。