发布 uid 和令牌数据时出错('WSGIRequest' 对象没有属性 'post')

getting error while posting data of uid and token ( 'WSGIRequest' object has no attribute 'post' )

我创建了基于 class 的视图来访问 uid 和 token 。这里我创建了一个网页,其中有一个激活用户的按钮。我正在向用户电子邮件发送一个 uid 和令牌。现在我想在用户单击按钮时 post 该 uid 和令牌。我为 post uid 和令牌创建此代码。但是在 posting (WSGIRequest' object has no attribute 'post)

上出错

views.py

class ActivationView(View):
def get (self, request, uid, token):
    print('get called in activate_user')
    return render(request, 'activate.html')

def post (self, request, uid, token):
    print('UID : ', uid)
    print('Token : ', token)
    payload = json.dumps({'uid': uid, 'token': token})
    print("payload : " , payload)
    protocol = 'https://' if request.is_secure() else 'http://'
    web_url = protocol + request.get_host() + '/'
    post_url = web_url + ACTIVATION_BASE_ROUTE
    print('post_url : ' + post_url)
    response = request.post(post_url, data = payload)
    return HttpResponse(response.text)

activate.html

    <form action="" method="post">
    {% csrf_token %}
           <td ><button type="submit">Click Here For Activate Account</button></td>
     </form>

我怎样才能 post 它在同一页上?

应该是requests not request

试试这个

import requests

class ActivationView(View):
    
    def post (self, request, uid, token):
        ...
        response = requests.post(post_url, data = payload)
        return HttpResponse(response.text)