from django.shortcuts import render
from django.http import HttpResponse
def register(request):
if request.method == 'POST':
name = request.POST['name'] #in this way we are collecting data
email= request.Post['email']
password = request.Post['password']
print(f'Name :{name}') #in this way we are printing the data
print(f'Email :{email}')
print(f'Password :{password}')
return HttpResponse('<h1> This is a post Request</h1>')
elif request.method == 'GET':
return HttpResponse('<h1> This is a get Request</h1>')
else:
return HttpResponse('<h1> This is an invalid Request</h1>')
While testing in postman using post request it is showing it is a post request. But in browser it shows this is a get request why is it neglating post request
smaranika hota is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
When something is typed into a browser’s address bar, it will almost always result in a GET request.
Thats the reason the url you paste in browser generate GET Response. If you want to submit the post request, make a html form and submit it as post.