Django Class Based View Pagination
Hi i want to paginating queryset(lectures). and i tried. but it doesn'work how can i do? class tag_detail(View): def get(self, request, pk): tag_hit = get_o
Solution 1:
Just make it a ListView
and you won't have to worry about how it all works since paginate_by
sets up pagination for you
class tag_detail(ListView): # TagDetailListView would be a better name
paginate_by = 2
template_name = 'web/html/tag/tag_detail.html'
model = LectureModel
ordering = '-id'
context_object_name = 'lectures'
def get_queryset(self):
return LectureModel.objects.filter(tags__id=self.kwargs['pk'])
Post a Comment for "Django Class Based View Pagination"