class InviteLoginForWebsiteMiddleware(object):

    def process_request(self, request):
        if request.session.get('has_invite') == True:
            return None
return csrf_protect(CustomLoginView.as_view())(request)
Django middleware with login and password which hides all the website pages