django midleware inside function is not recognized it is giving me error 'function' object has no attribute 'get'

30 Views Asked by At

error 'function' object has no attribute 'get' .inside dmy_middleware not recognized here is code

def my_function(get_response):_
    print('hi')
    def dmy_middleware(request):
        response = get_response(request)
        print('go')
        return response
    return my_function
1

There are 1 best solutions below

0
Sirwill98 On

The error is because you are returning the middleware and not the function inside, this code works for me.

def my_function(get_response):_
    print('hi')
    def dmy_middleware(request):
        response = get_response(request)
        print('go')
        return response
    return dmy_middleware