Created
September 27, 2012 21:45
-
-
Save hcarvalhoalves/3796643 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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