'Range slider value used in django for advanced search
I have a question. I am attempting to make a multi-value search bar but am having errors having it complete the search.
Aim: To be able to search using integer values for people, data, Calls, Messages, and text input.
The error being received:
MultiValueDictKeyError at /find
'people'
Request Method: POST
Request URL: http://127.0.0.1:8000/find
Django Version: 4.0.3
Exception Type: MultiValueDictKeyError
Exception Value:
'people'
Exception Location: C:\Python310\lib\site-packages\django\utils\datastructures.py, line 86, in getitem
Python Executable: C:\Python310\python.exe
Python Version: 3.10.4
'''
Python Path:
['C:\Users\TOSHIBA\Documents\django_projects\Daniskapp\Daniskapp',
'C:\Python310\python310.zip',
'C:\Python310\DLLs',
'C:\Python310\lib',
'C:\Python310',
'C:\Python310\lib\site-packages']
Server time: Wed, 04 May 2022 11:46:59 +0000 '''
Views.py file:
def find(request):
if request.method=="POST":
searched = request.POST['searched']
people = request.POST['people']
SearchData = request.POST['Data']
SearchCalls = request.POST['calls']
SearchMessages = request.POST['demo']
results = informationBase.objects.filter(title__contains=searched,People=people,Data__lte=SearchData,Calls__lte=SearchCalls,Messages__lte=SearchMessages)
return render(request,'finder.html', {'results': results})
'''
'''
Model :
'''
'''
class informationBase(models.Model):
title = models.CharField(max_length=200)
People = models.IntegerField()
Data = models.IntegerField()
Calls = models.IntegerField()
Messages = models.IntegerField()
body = models.CharField(max_length=100000000)
created_at = models.DateTimeField(default =datetime.now(), blank= True)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|