Home > Software design >  What does request.POST.get method return in Django?
What does request.POST.get method return in Django?

Time:11-28

What does request.POST.get("a") return while "a" is the reference to following html

label for = "a">ADDED ITEMS:</label>
<input hidden type="number" name="a" id="a">

def myfunc():

if request.method == "POST":
    a = request.POST.get("a");
    obj = TransferedItems(item_id = a);
    obj.save();
    return HttpResponse("sent")
else:
    return HttpResponse("form submission failed")

I am new at Django and I am unable to find what does request.POST.get return. Please guide me on my question.

CodePudding user response:

It returns the value of the field with name a that your sending from HTML. If the value doesn't exists, it returns None

  • Related