Django error handling - "exception" is not accessed - Pylance

I have the following views.py to handle 400, 403 and 404 error requests

def handler400(request, exception):
    return render(request, "400.html", status=400)

def handler403(request, exception):
    return render(request, "403.html", status=403)

def handler404(request, exception):
    return render(request, "404.html", status=404)

In my Project's urls.py file I have:

handler400 = 'tasks.views.handler400'
handler403 = 'tasks.views.handler403'
handler404 = 'tasks.views.handler404'
handler500 = 'tasks.views.handler500'

The app that the views are in is named tasks.

DEBUG = False is in my settings.py file.

When I purposefully create an error, the error handler does not work.

As mentioned, in my views.py file the "exception is not accessed - Pylance."

Any help would be greatly appreciated.

Back to Top