Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from django.views.generic.list import ListView
from django.conf.urls.defaults import patterns, url
from models import Movie
class MovieListView(ListView):
paginate_by = 50
def get(self, request, *args, **kwargs):
self.filter = MovieFilterSet(data=request.GET, queryset=self.queryset)
return super(MovieListView, self).get(request, *args, **kwargs)
def get_queryset(self):
return self.filter.qs
def get_context_data(self, **kwargs):
context = super(MovieListView, self).get_context_data(**kwargs)
context['filter'] = self.filter
return context
urlpatterns = patterns(None,
url(regex=r'^$',
name='movie_list',
view=MovieListView.as_view(
queryset=Movie.objects.all(),
template_name='my_custom_template.html')),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment