我想将@cache_page
添加到基于类的视图中,但是由于我的网址url(r'^/(?P<shortcut>coming-soon)$', MovieList.as_view(), name='movie_list_coming_soon'),
的方式,它会带来错误MovieList没有.as_view
类MovieList是:
class MovieList(ListView):
model = Movie
paginate_by = 20
context_object_name = 'movies'
category = None
venue = None
date = None
slug_level = ""
def get_queryset(self):
today = datetime.date.today()
qs = Movie.objects.filter(visible=True,).order_by('-hot', '-showing', 'name')
if self.request.mobile:
self.template_name = 'mobile/movies.html'
if self.kwargs.get('category', None):
slugs = self.kwargs['category'].strip('/').split('/')
self.category = get_object_or_404(Category, slug=slugs[-1])
category_ids = [c.id for c in self.category.get_child_categories()]
category_ids.append(self.category.id)
qs = qs.filter(categories__in=category_ids)
if self.kwargs.get('venue', None):
.....