diff --git a/core/templates/guest.html b/core/templates/guest.html index 30f4a0f..4c1f995 100644 --- a/core/templates/guest.html +++ b/core/templates/guest.html @@ -3,6 +3,7 @@ {% load i18n custom_filters %} {% load static i18n %} +{% load pagination %}
@@ -159,6 +160,7 @@ {% endfor %} + {% pagination request paginator page_obj %} {% endblock %} diff --git a/core/urls.py b/core/urls.py index f702ede..ecd28e2 100644 --- a/core/urls.py +++ b/core/urls.py @@ -11,7 +11,7 @@ urlpatterns = [ url(r'^logout/$', auth_views.logout, {'next_page': 'core:home'}, name='logout'), url(r'^notification/([0-9]+)/$', views.processNotification, name='notification_read'), url(r'^getNotifications/$', views.getNotifications, name='getNotifications'), - url(r'^guest/$', views.guest, name='guest'), + url(r'^guest/$', views.GuestView.as_view(), name='guest'), #Reset Password diff --git a/core/views.py b/core/views.py index 60de9e3..f96dd4b 100644 --- a/core/views.py +++ b/core/views.py @@ -6,7 +6,7 @@ from .decorators import log_decorator from django.contrib import messages from django.shortcuts import render, redirect from django.template.loader import render_to_string -from django.views.generic import CreateView, UpdateView +from django.views.generic import CreateView, UpdateView, ListView from django.http import HttpResponse, JsonResponse from django.core.mail import send_mail,BadHeaderError from django.conf import settings @@ -120,9 +120,18 @@ def getNotifications(request): data['amountGotten'] = amountGotten return JsonResponse(data) -def guest (request): - context = { - 'courses': Course.objects.filter(public=True), - 'categories': CourseCategory.objects.all(), - } - return render(request, 'guest.html', context) \ No newline at end of file + +class GuestView (ListView): + + template_name = 'guest.html' + context_object_name = 'courses' + paginate_by = 10 + + def get_queryset(self): + return Course.objects.filter(public=True) + + + def get_context_data (self, **kwargs): + context = super(GuestView, self).get_context_data(**kwargs) + context['categories'] = CourseCategory.objects.all() + return context -- libgit2 0.21.2