[Fixed]-HTML POST form in Django giving TypeError when submitted

1👍

Using the APIView class is pretty much the same as using a regular View class, as usual, the incoming request is dispatched to an appropriate handler method such as .get() or .post()

If you doing a POST request.You have to do

def post(self, request, format=None):
    #rest of code

0👍

 display_id = request.POST.get("textfield")

error with this line. you are missing self. here it is returning NoneType. And change your method to post

def post(self, request, format=None):


 display_id = self.request.POST.get("textfield")

try:
       display_id = int(display_id) 
except ValueError: 
       display_id = "here you give default value" 

you got this error because you are trying to pass non-integer value as a string

Leave a comment