Source code for derrida.outwork.views
from django.views.generic import ListView
from haystack.query import SearchQuerySet
from haystack.inputs import Clean, Raw
from derrida.outwork.models import Outwork
[docs]class OutworkListView(ListView):
model = Outwork
template_name = 'outwork/outwork_list.html'
paginate_by = 16
[docs] def get_queryset(self):
# restrict to published articles
sqs = SearchQuerySet().models(self.model).filter(published=Raw(True))
if self.request.GET.get('query', None):
sqs = sqs.filter(content=Clean(self.request.GET['query']))
# default sort ?
return sqs
# return Outwork.objects.published(for_user=self.request.user)