I am using django-filter

I have create the the filter as follows:
filters.py
import django_filters
from .models import Job


class JobFilter(django_filters.FilterSet):
    class Meta:
        model = Job
        fields = ['practice_type']

And I have created the following view:
from .models import Job
from .filters import JobFilter


def jobs_list(request):
    filter = JobFilter(request.GET, queryset=Job.objects.all())
    return render(request, 'jobs/jobs_list.html', {'filter': filter})

job_list.html
And then a templater as follows:
{% block content %}
    <form action="" method="get">
        {{ filter.form.as_p }}
        <input type="submit" />
    </form>
    {% for job in filter %}
        {{ job.name }} <br />
    {% endfor %}
{% endblock %}

Everything is fine and the filter shows on the relevant page

However on pressing submit no results are returned.

I know this is probably something quite simple but I have been staring at 
this for so long now any help would be appreciated.

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/c454499d-ddfe-48b8-be67-53a7535de0b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • Django Filter 'David Turner' via Django users

Reply via email to