Hi, No idea what’s going on here, I’ve never seen this before, but I’m using django-filters but the actual search bar is not showing up, I thought that was part of the filters package and got rendered as part of using it, but all that shows is the submit button. What am I doing wrong?
filter.py
from django.contrib.auth.models import User
import django_filters
from .models import Project
class ProjectFilter(django_filters.FilterSet):
class Meta:
model = Project
fields = ['user', 'title']
views.py:
def search_view(request):
project_list = Project.objects.all()
project_filter = ProjectFilter(request.GET, queryset=(project_list)
return render(request, 'project_portal/filter.html', {'filter': project_filter})
urls.py:
path('search/', search_view, name='search'),
html:
<!DOCTYPE html>
<div>
<form method="get">
{{ filter.form.as_p }}
<input type="submit"/>
</form>
{% for user in filter.qs %}
{{ user.title }}
{% endfor %}
</div>