The global POST variable allows you to access the data sent with the POST method by* input name*. See more info https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Sending_and_retrieving_form_data .
Your html: <form action="/action_page.php"> First name:<br> <input type="text" name="search"> <br> Last name:<br> <input type="text" name="search1"> <br><br> <input type="submit" value="Submit"> </form> On Thursday, 4 April 2019 09:43:51 UTC+2, Abhineet Baranwal wrote: > > Thanks for the help, this is showing only one value in dictionary at a > time . There is no fault here but i have a question can we run multiple > search query in same page with different id ? And it shows that error even > now > > On Wed, Apr 3, 2019 at 5:56 PM dvij parekh <[email protected] > <javascript:>> wrote: > >> >> seems like search1 key is containg multi value dictionary and you are >> checking it with == which is for single value >> after >> *search1 = request.POST['search1'] * >> put >> *print(* *search1* *)* >> *return "hello"* >> >> and comment code remaining below ,check terminal it will show you how >> many value you have in dictionary >> >> >> On Wed, Apr 3, 2019 at 5:03 PM Abhineet Baranwal <[email protected] >> <javascript:>> wrote: >> >>> >>> *this is my views file which creates an error like >>> django.utils.datastructures.MultiValueDictKeyError: 'search1' . Can anyone >>> tell me where i go wrong?* >>> >>> *def viewstr(request):* >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> * views = create_store.objects.all() brn = >>> Prod_Brand.objects.all() mi = '' if request.method == 'POST': >>> # mi = '' search1 = request.POST['search1'] if search1 == '' >>> : pass else: mi = >>> create_store.objects.filter(Q(select_brand__Brand__icontains=search1)) >>> >>> if mi: return >>> render(request,'viewstr.html',{'vi':mi,'brn':brn}) search = >>> request.POST['search'] if search == '' : pass else >>> : mi = >>> create_store.objects.filter(Q(id__icontains=search)) if >>> mi: return >>> render(request,'viewstr.html',{'vi':mi,'brn':brn}) return >>> render(request,'viewstr.html',{'viewstr':viewstr,'vi':mi,'brn':brn})* >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected] <javascript:>. >>> To post to this group, send email to [email protected] >>> <javascript:>. >>> Visit this group at https://groups.google.com/group/django-users. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-users/cdafd13a-46b5-471d-a927-b3d5d8e58f5c%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/django-users/cdafd13a-46b5-471d-a927-b3d5d8e58f5c%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/CAF-XeXYVy%3DyvtRrm9pOyERySbbAaQ%2BwarU-56ySpCnNvk%2B1Mjw%40mail.gmail.com >> >> <https://groups.google.com/d/msgid/django-users/CAF-XeXYVy%3DyvtRrm9pOyERySbbAaQ%2BwarU-56ySpCnNvk%2B1Mjw%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/12e2535d-9d3f-47ff-8e6a-791a75711a82%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

