Django WSGIRequest 参数错误

blu*_*inc 1 python django django-wsgi

AttributeError("'WSGIRequest' object has no attribute 'args'",) 当我尝试拨打这个电话时,我得到了这个

GET /sign_s3/?s3_object_type=image/jpeg&s3_object_name=default_name

我错过了什么吗?

*args, **kwargs除了请求,我还需要包括吗?

这是回溯:

            response = middleware_method(request, callback, callback_args, callback_kwargs)
            if response:
                break
    if response is None:
        wrapped_callback = self.make_view_atomic(callback)
        try:
            response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
        except Exception as e:
            # If the view raised an exception, run it through exception
            # middleware, and if the exception middleware returns a
            # response, use that. Otherwise, reraise the exception.
            for middleware_method in self._exception_middleware:
                response = middleware_method(request, e)
Run Code Online (Sandbox Code Playgroud)

风景:

@login_required()
def sign_s3(request):
    object_name = request.args.get('s3_object_name') 
Run Code Online (Sandbox Code Playgroud)

Nig*_*nel 5

HttpRequest对象没有args属性。

你应该使用

request.GET.get('s3_object_name')
Run Code Online (Sandbox Code Playgroud)

得到s3_object_name value

Django文档具有优良的部分HttpRequest