Commits

Luke Plant  committed 12d58d5

Added easyfilters to sermons page

  • Participants
  • Parent commits 9b7270b

Comments (0)

Files changed (2)

File sermons/templates/sermons/index.html

 
 {% autopaginate sermons 30 %}
 
+<h1>Filters:</h1>
+{{ sermonsfilter }}
+
 {% paginate %}
 
 {% for sermon in sermons %}

File sermons/views.py

 from django.conf import settings
 from django.shortcuts import render
+from django_easyfilters import FilterSet
 
 from sermons.models import Sermon
 
+class SermonFilterSet(FilterSet):
+    fields = ['speaker']
+
 def index(request):
     sermons = Sermon.objects.filter(published=True)
-    return render(request, "sermons/index.html", {'sermons': sermons})
+    sermonsfilter = SermonFilterSet(sermons, request.GET)
+    return render(request, "sermons/index.html", {'sermonsfilter': sermonsfilter,
+                                                  'sermons': sermonsfilter.qs})