Django 2.2 breaks previously working views/urls

前端 未结 4 975
花落未央
花落未央 2021-01-18 23:52

Decided to take out Django 2.2 for a spin (project is currently running 2.1.8) and now I can\'t even get the server to start. I have been maintaining this project for nearly

4条回答
  •  既然无缘
    2021-01-19 00:17

    It seems the custom error handlers are the cause of it.

    In Django 2.1 I had a custom handler for a 500 Error error like this:

    def error_500_view(request, exception):
        return render(request,'500.html')
    

    But in Django 2.2 it seems that the 500 Error handler only takes 1 argument, so I changed to:

    def error_500_view(request):
        return render(request,'500.html')
    

    And everything is working normal again.

    So make sure your 404 Error handler is something like:

    def notfound(request, exception):
        return render(request,'400.html')
    

提交回复
热议问题