I created class based view where In get method I am calling html page activate.html. and created post method where I posting some json data. I want to redirect same page and want to post data.
When I am running activate.html page I get it but when I click on button for activate user Its printing same which I print in get method
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()
djoser_url = getattr(settings, 'DJOSER.ACTIVATION_URL')
post_url = web_url + djoser_url
print('post_url : ' + post_url)
response = request.post(post_url, data = payload)
return HttpResponse(response.text)
I want to print uid and token in json format when I click on post button from html.
activate.html
<form action="" method="post">
{% csrf_token %}
<td input type="submit"><a href="" target="_blank" >Click Here For Activate Account</a></td>
</form>
change your form
<form action="" method="post">
{% csrf_token %}
<td ><button type="submit">Click Here For Activate Account</button></td>
</form>
this will works.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments