[Answered ]-TypeError at /studentform Field 'prn_no' expected a number but got ('1',)

1👍

The error says prn_no is expected to be a string whereas a tuple is assigned to prn_no. To fix it, in your views.py file, you should remove commas at the end of each line.

def studentform(request):
    if request.method == "POST":
        prn_no = request.POST.get('prn_no')
        fname = request.POST.get('fname')
        lname = request.POST.get('lname')
        dob = request.POST.get('dob')
        address = request.POST.get('address')
        gender = request.POST.get('gender')
        standard = request.POST.get('standard')
        guardian_id = request.POST.get('guardian_id') 

        s1 = student1(prn_no = prn_no , fname = fname , 
                             lname = lname, dob = dob , address = address , 
                              gender = gender, standard = standard , guardian_id = guardian_id )

        s1.save()
    return render(request,'studentform.html')
👤black

Leave a comment