Django(TypeError: ожидалась строка или байтоподобный объект)
Поскольку я использую django и mongodb, мне нужно отправить значения с помощью созданной html формы и сохранить их в базе данных, но эта ошибка возникает, когда я отправляю значение в форме. Я поделюсь с вами своим кодом.
Мой шаблон template/insert.html и файл Jquery,
А мой views.py имеет вид,
def home(request):
return render(request,'insert.html')
def Adddata(request):
print("q")
if request.method == "POST":
print("pp")
print(request.POST.get('id'))
id = request.POST.get('id')
applied_on = request.POST.get('applied_on')
city = request.POST.get('city'),
country = request.POST.get('country'),
courseId = request.POST.get('courseid'),
courseName = request.POST.get('coursename'),
created = request.POST.get('created'),
dob = request.POST.get('dob'),
eligibility_verified = request.POST.get('eligibility_verified'),
email_id = request.POST.get('email_id' ),
exactdup = request.POST.get('exactdup'),
exam_registration = request.POST.get('exam_registration'),
ilearnUserID = request.POST.get('ilearnuserid'),
last_action_by = request.POST.get('last_action_by'),
localChapterId = request.POST.get('localchapterid'),
localChapterName = request.POST.get('localchaptername'),
mobile_no = request.POST.get('mobile_no'),
modified = request.POST.get('modified'),
nationalid = request.POST.get('nationalid'),
member=example.objects.create(id=id,applied_on=applied_on,city=city,country=country, courseId=courseId, courseName=courseName, created=created, dob=dob,eligibility_verified=eligibility_verified,email_id=email_id,exactdup=exactdup,exam_registration=exam_registration,ilearnUserID=ilearnUserID,last_action_by=last_action_by,localChapterId=localChapterId,localChapterName=localChapterName,mobile_no=mobile_no,modified=modified,nationalid=nationalid)
data=None
if member:
data={
'bool':True
}
else:
data={
'bool':False
}
return JsonResponse(data)
и urls.py является,
path('home',views.home,name='home'),
url('new',views.Adddata,name='Adddata')
Пожалуйста, помогите мне с вашим добром.