中间件dejango-建立网站-网址错误

时间:2018-10-05 20:11:07

标签: python error-handling django-middleware

我正在使用django / python建立一个网站,并且我的网页最初可以正常工作,但是随着我的继续,我遇到了很多错误...我试图为中间件添加代码,但没有帮助。我不想触碰这些核心文件...我该怎么办?我正在遵循一个教程,但是对我的网站进行了相应的调整。我在另一页上还有其他几个错误,但是我觉得如果我能理解如何解决这些错误,我可以找出其余的希望。

谢谢您4个帮助!!!!

此装饰器自动应用于所有中间件,以确保 没有中间件泄漏异常,并且堆栈中的下一个中间件 可以依靠获得响应而不是异常。

"""
@wraps(get_response)
def inner(request):
    try:
        response = get_response(request) ...
    except Exception as exc:
        response = response_for_exception(request, exc)
    return response
return inner

下一个错误

break
    if response is None:
        wrapped_callback = self.make_view_atomic(callback)
        try:
            response = wrapped_callback(request, *callback_args, **callback_kwargs)
        except Exception as e:
            response = self.process_exception_by_middleware(e, request) ...


  # Complain if the view returned None (a common error).
        if response is None:
            if isinstance(callback, types.FunctionType):    # FBV
                view_name = callback.__name__
            else:                                           # CBV

错误#3

  response = middleware_method(request, callback, callback_args, callback_kwargs)
            if response:
                break
        if response is None:
            wrapped_callback = self.make_view_atomic(callback)
            try:
                response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
            except Exception as e:
                response = self.process_exception_by_middleware(e, request)
        # Complain if the view returned None (a common error).
        if response is None:
            if isinstance(callback, types.FunctionType):    # FBV

0 个答案:

没有答案