简体   繁体   English

TypeError:正好接受4个参数(给定3个):请求参数未被传递

[英]TypeError : takes exactly 4 arguments (3 given) : request argument is not being passed

So i have this in my views.py 所以我在views.py中有这个

def rate_api(request, rating_user_id, rated_user_id, value):
    user.profile = request.user.get_profile()
    return HttpResponse('success')

And this in my urls.py 这在我的urls.py中

url(r'^rate_api/(?P<rating_user_id>.+?)/(?P<rated_user_id>.+?)/$', 'v1_1.views.rate_api'),

And this in my template (profile.html) 这在我的模板(profile.html)中

$.ajax({
          type: "GET",
          url: "../../rate_api/variable1/variable2/variable3",
          data: '',
        });

And I get the following error 我收到以下错误

TypeError at /rate_api/variable1/variable2/variable3/
rate_api() takes exactly 4 arguments (3 given)

Request Method: GET

I believe that the parameter request is not being passed. 我相信参数请求没有被传递。 How can i fix this :/ 我怎样才能解决这个问题 :/

不,它是未传递的value参数,因为您没有在正则表达式中捕获它。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM