3๐
โ
So to get the form values in the views, you must do like form_val = request.GET.get('field_name', <default_value>)
, so to add a few lines in the code
def allresults(request):
# this will get the value of the selected item, print this to know more
mahina = request.GET.get('mahina', None)
#Just writing the below query field month randomly, since the models isn't posted
results = Results.objects.filter(month=mahina)
# We don't need to give GET since by default it is a get request
# Since there are multiple objects returned, you must iterate over them to access the fields
for r in results:
month = r.month
year = r.year
return render(request, 'results/allresults.html', {'results': results}
๐คSammy J
Source:stackexchange.com