This is the views.py file section,
class filterTask(View):
def get(self, request):
return render(request, 'filter-task.html');
def output(request):
form = Taskform
if request.method == 'GET':
form = Taskform(request.GET.get('priorityChoice'))
ans = Task.objects.filter(priority = form).values()
return redirect(request, 'output.html',context={'ans':ans})
This is the filter-task.html file
{% include 'base.html' %}
`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<a href="{% url 'index' %}">Go To Homepage</a>
<body>
<h3>Filter Task by Priority</h3>
<form method="get" autocomplete="off">
{% csrf_token %}
<label id="priorityChoice">Enter the priority </label>:
<select id="priorityChoice" name="priorityChoice" required>
<option value="low">low</option>
<option value="mid">mid</option>
<option value="high">high</option><br>
</select><br><br>
<input type="submit" value="Submit"/>
</form>
</body>
</html>`
I am trying to filter a specific attribute of an object from the html file by getting the answer from a dropdown option, Kindly help me.
I am trying to filter a specific attribute of an object from the html file by getting the answer from a dropdown option, Kindly help me.
New contributor
Srinivas Saravanan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.