JAYESH rathi
JAYESH rathi

Reputation: 45

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

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

Upvotes: 0

Views: 30

Answers (1)

Sirwill98
Sirwill98

Reputation: 309

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

Upvotes: 0

Related Questions