from django.views.generic import ListView from .models import Course class CoursesView(ListView): model = Course context_object_name = "course_items" paginate_by = 6 def get_template_names(self): if self.request.is_ajax(): return 'course/course_items.html' return "course/courses.html"