-Specify the Http status code in Django and return. -Ajax communication is performed with jQuery, and I want to force fail to be executed under specific conditions.
・ Windows10 premium ・ VScode ・ JQuery
Ajax code omitted This is the processing when an appropriate character string is transmitted and the character "test`" is not included in the transmitted character string.
test.py
import HttpResponse
get_post = request.POST["testData"]
if not "test" in get_post:
response = HttpResponse(status=500) #Specify 500 as the status code
return response
Recommended Posts