简体   繁体   English

无法识别 function 中的 django 中间件中间件给我错误“功能” object 没有属性“获取”

[英]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错误'function' object has no attribute 'get'.inside dmy_middleware not recognize 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

The error is because you are returning the middleware and not the function inside, this code works for me.错误是因为您返回的是中间件,而不是里面的 function,这段代码对我有用。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 'function' object has no attribute 'get' 错误在 django - 'function' object has no attribute 'get' error in django 'function' object 在 django 中没有属性 'get' - 'function' object has no attribute 'get' in django Django 错误 - 'function' 对象没有属性 'MyForm' - Django error - 'function' object has no attribute 'MyForm' Django错误:“函数”对象没有属性“保存” - Django Error: 'function' object has no attribute 'save' 我正在使用一个函数将我的应用程序设置在屏幕中央,但它给了我错误“builtin_function_or_method”对象没有属性“center” - I am using a function to set my app at centre of the screen but it is giving me error 'builtin_function_or_method' object has no attribute 'center' 'function' 对象没有属性 'objects' Django,帮帮我 - 'function' object has no attribute 'objects' Django, help me Django属性错误:“函数”对象没有属性“ is_usable” - Django Attribute Error: 'function' object has no attribute 'is_usable' “属性错误/功能”object 在 Django 中没有属性“对象” - 'Attribute Error/ function' object has no attribute 'objects' in Django 模块在对象内部不可用(错误:“功能”对象没有属性“选择”) - module not available inside object (Error: 'function' object has no attribute 'select') 异常`'function'对象没有自定义装饰器在django中触发的属性'get' - Exception `'function' object has no attribute 'get'` triggered in django by custom decorator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM