2👍
I am surprised to see that none of you didn’t noticed that he has define method: “POST” in his ajax and his function is used on “GET” request.
And the main reason he is getting the output for print request.method = “GET” and 500 error is because of using window.location.href=”create_post/” in his ajax success function. Every request is by default a get request unless we explicitly define it “POST” or any other.
So here it goes like this,
– Ajax calls the url via POST, for unknown reason the response comes in success function(weird coz according to the view posted POST method return nothing to ajax request).
– The success function again calls the same url(page refresh) via a GET request and he sees print request.method as “GET” with 500 error coz this is wrong way to do so.
-1👍
your ajax method is post, so i think your views.py may try this
def create_post(request):
if request.method == 'POST':
First_name=request.POST['F_Name']
Last_Name=request.POST["L_Name"]
Email_address=request.POST["Eadd"]
Pass=request.POST["Password"]
return HttpResponse("<html><body>hi this is me .</body></html>")
- [Answer]-Genericizing an iterative view model
- [Answer]-Django + Extjs 5.1.1
- [Answer]-Grabbing field from a query set in Django
- [Answer]-Django template rendering extend tag incorrectly