Django return "internal" sign in form

I try to create my own session middleware and my uauth system using Django. I've got the following code:

class CheckSessionsExistMiddleware:
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        response = self.get_response(request)
        response.status_code = 401
        response.reason_phrase = 'Unauthorized'
        realm = 'some_app'
        response['WWW-Authenticate'] = f'Basic real={realm}'
        return response

When i set to respone header 'WWW-Authenticate' the string that contains word 'Basic', django returns the following form and i do not understand why:

Link to example of sign in form that django returns:

Is there a way to disable this behavior?

I expected that Django just return to client the header 'WWW-Authenticate' with value 'Basic realm=some_app' without sign in form.

Back to Top