Commit f9a2a4163efadfb740fb09867578f66e995803f3
1 parent
b9b059c8
Exists in
master
and in
5 other branches
placing the pagination again in list curses #189
Showing
2 changed files
with
23 additions
and
2 deletions
Show diff stats
courses/templates/course/index.html
@@ -104,5 +104,26 @@ | @@ -104,5 +104,26 @@ | ||
104 | {% trans 'No courses found' %} | 104 | {% trans 'No courses found' %} |
105 | {% endif %} | 105 | {% endif %} |
106 | </div> | 106 | </div> |
107 | + <div class="col-md-12"> | ||
108 | + <nav aria-label="Page navigation"> | ||
109 | + <ul class="pagination"> | ||
110 | + {% if page_obj.has_previous %} | ||
111 | + <li> | ||
112 | + <a href="?page={{ page_obj.previous_page_number }}"><span><<</span></a> | ||
113 | + </li> | ||
114 | + {% endif %} | ||
115 | + {% for page_number in paginator.page_range %} | ||
116 | + <li{% if page_obj.number == page_number %} class="active"{% endif %}> | ||
117 | + <a href="?page={{ page_number }}">{{ page_number }}</a> | ||
118 | + </li> | ||
119 | + {% endfor %} | ||
120 | + {% if page_obj.has_next %} | ||
121 | + <li> | ||
122 | + <a href="?page={{ page_obj.next_page_number }}"><span>>></span></a> | ||
123 | + </li> | ||
124 | + {% endif %} | ||
125 | + </ul> | ||
126 | + </nav> | ||
127 | + </div> | ||
107 | <script type="text/javascript" src="{% static 'js/course.js' %}"></script> | 128 | <script type="text/javascript" src="{% static 'js/course.js' %}"></script> |
108 | {% endblock %} | 129 | {% endblock %} |
courses/views.py
@@ -30,7 +30,7 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): | @@ -30,7 +30,7 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): | ||
30 | queryset = Course.objects.all() | 30 | queryset = Course.objects.all() |
31 | template_name = 'course/index.html' | 31 | template_name = 'course/index.html' |
32 | context_object_name = 'courses' | 32 | context_object_name = 'courses' |
33 | - paginate_by = 2 | 33 | + paginate_by = 5 |
34 | 34 | ||
35 | def get_context_data(self, **kwargs): | 35 | def get_context_data(self, **kwargs): |
36 | context = super(IndexView, self).get_context_data(**kwargs) | 36 | context = super(IndexView, self).get_context_data(**kwargs) |
@@ -197,7 +197,7 @@ class DeleteCourseView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView): | @@ -197,7 +197,7 @@ class DeleteCourseView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView): | ||
197 | return context | 197 | return context |
198 | 198 | ||
199 | 199 | ||
200 | -class CourseView( NotificationMixin, generic.DetailView): | 200 | +class CourseView(NotificationMixin, generic.DetailView): |
201 | 201 | ||
202 | login_url = reverse_lazy("core:home") | 202 | login_url = reverse_lazy("core:home") |
203 | redirect_field_name = 'next' | 203 | redirect_field_name = 'next' |