SLUGIFY = 'django.template.defaultfilters.slugify'
BLOG_POST_PER_PAGE = 200
+ARTICLE_PER_PAGE = 4 # just for tests because we haven't got enough content
# The numeric mode to set newly-uploaded files to. The value should be
# a mode you'd pass directly to os.chmod.
from dal import autocomplete
from dal_select2_queryset_sequence.views import Select2QuerySetSequenceView
from mezzanine_agenda.models import Event
+from mezzanine.utils.views import paginate
+from mezzanine.conf import settings
from organization.magazine.models import Article, Topic, Brief
from organization.network.models import DepartmentPage
from organization.pages.models import CustomPage
context = super(BriefDetailView, self).get_context_data(**kwargs)
return context
+
class BriefListView(SlugMixin, ListView):
model = Brief
def get_context_data(self, **kwargs):
context = super(TopicDetailView, self).get_context_data(**kwargs)
+ # paginate "manually" articles because we are not in a ListView
+ articles = paginate(self.object.articles.all(), self.request.GET.get("page", 1),
+ settings.ARTICLE_PER_PAGE,
+ settings.MAX_PAGING_LINKS)
+ context['articles'] = articles
return context
<div class="container">
<div class="row">
- {% for article in topic.articles.all %}
+ {% for article in articles %}
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-6">
{% include 'magazine/article/includes/article_card.html' %}
</div>
{% endfor %}
</div>
</div>
-
+ {% pagination_for articles %}
{% endblock %}