title: Django pagination return all elements but still paginate
body: <p>I am trying to do something supposed to be simple and easy with django :</p>
  
  <p>have a pagination of a list of items.</p>
  
  <p>So, I have an article page, I want to display a maximum of 10 articles per page, next page = 10 next articles etc.</p>
  
  <p>You can order them by some categories as sources or dates.</p>
  
  <p>So, when I arrive on my mydomaine.com/articles/ I have all my elements displayed.</p>
  
  <p>If I sort by sources, as this views.py show :</p>
  
  <pre><code>class SourceEntriesView(ContextSourcesMixin, BaseArticleView, BaseArticleListView):
  model = Article
  context_object_name = 'article_list'
  template_name = 'base_templates/template_press.html'
  _source = None
  paginate_by = get_setting('PAGINATION')
  view_url_name = 'djangocms_press:articles-source'
  
  @property
  def source(self):
      if not self._source:
          try:
              source_qs = ArticleSource.objects.active_translations(
                  get_language(),
                  slug=self.kwargs['source']
              )
  
              #source_qs = source_qs.filter(site=Site.objects.get_current().pk)
              self._source = source_qs.latest('pk')
          except ArticleSource.DoesNotExist:
              raise Http404("ArticleSource does not exist for this site")
      return self._source
  
  def get_queryset(self):
      qs = super(SourceEntriesView, self).get_queryset()
      if 'source' in self.kwargs:
          qs = qs.filter(sources__pk=self.source.pk)
      return qs
  
  def get_context_data(self, **kwargs):
      kwargs['source'] = self.source
      return super(SourceEntriesView, self).get_context_data(**kwargs)
  </code></pre>
  
  <p>Once the ajax call is made to load this view and display the articles sorted by source, I have my 10 items ! (well, I am trying with 4 while testing).</p>
  
  <p>So why isn't it working on the main page.</p>
  
  <p>Here are more explanations with my code :</p>
  
  <pre><code>''' Main article display view '''
  class ArticleListView(FormMixin, BaseArticleListView, ContextSourcesMixin):
    model = Article
    context_object_name = 'article_list'
    template_name = 'base_templates/template_press.html'
    view_url_name = 'djangocms_press:articles-list'
    form_class = SourcesRegionsFilterForm
    paginate_by = get_setting('PAGINATION')
  
  
  def get_form_kwargs(self):
      return {
          'initial': self.get_initial(),
          'prefix': self.get_prefix(),
          'data': self.request.GET or None,
          'request': self.request,
      }
  
  def get(self, request, *args, **kwargs):
      """
      Handle the form submissions to filter by Sources and regions
      First_object is use for pagination
      """
      context = {}
  
      self.object_list = self.get_queryset().order_by("-date_realization")
  
      first_object = 0
  
      if 'article' in self.request.GET:
          try:
              project_id = int(request.GET['article'])
              context['article_render'] = self.object_list.get(pk=project_id)
          except (Article.DoesNotExist, ValueError):
              pass
  
      form = self.get_form(self.form_class)
  
      if form.is_valid():
          if form.cleaned_data['regions']:
              self.object_list = self.object_list.filter(
                  Q(regions__continent=form.cleaned_data['regions']) | Q(global_regions=True)).distinct()
  
      context.update(self.get_context_data(form=form))
  
      context['load_more_url'] = self.get_load_more_url(request, context)
  
      context[self.context_object_name] = self.object_list
      context['object_list'] = self.object_list
      source_qs = ArticleSource.objects.active_translations(get_language())
      context['sources_list'] = source_qs
      date_realization_for_articles = Article.objects.values_list('date_realization',
                                                          flat=True).distinct()
      context['dates_realization'] = date_realization_for_articles.dates('date_realization', 'month', order="DESC")
  
      return self.render_to_response(context)
  
  def get_load_more_url(self, request, context):
      args = request.GET.copy()
      return '?{}'.format(args.urlencode())
  
  def render_to_json_response(self, context, **response_kwargs):
      if 'current_app' not in context:
          context['current_app'] = resolve(self.request.path).namespace
  
      c = RequestContext(self.request, context)
  
      html_items_list = render_to_string(
          'base_templates/template_press.html',
          context,
          context_instance=c)
  
      html_items_list = html_items_list.strip()
  
      json_response = {
          'html_items_list': html_items_list,
          'load_more_url': self.get_load_more_url(self.request, context),
      }
  
      return JsonResponse(json_response)
  
  def render_to_response(self, context):
      if self.request.is_ajax():
          response = self.render_to_json_response(context)
      else:
          response = super(ArticleListView, self).render_to_response(context)
      return response
  </code></pre>
  
  <p>This was the main view that displays articles.</p>
  
  <p>my settings, very simple but easier to use :</p>
  
  <pre><code>def get_setting(name):
    from django.conf import settings
    from meta_mixin import settings as meta_settings
  
    default = {
      'PRESS_PAGINATION': getattr(settings, 'PRESS_PAGINATION', 4),
    }
    return default['PRESS_%s' % name]
  </code></pre>
  
  <p>I also tried to pass the paginated_by in the article-list url but the result is the same.</p>
  
  <p>here is my part of template suppose to be paginated :</p>
  
  <pre><code>    {% if article_list %}
      &lt;div id="articles-list" class="col-md-12"&gt;
          {% for article in article_list %}
          &lt;div class="row article"&gt;
              &lt;div class="col-md-2"&gt;
                  {{ article.date_realization|date:"F d, Y" }}
              &lt;/div&gt;
              &lt;div class="col-md-2"&gt;
                  {{ article.source }}
              &lt;/div&gt;
              &lt;div class="col-md-2"&gt;
              {% for region in article.regions.all %}
                  {{ region.name }}
              {% endfor %}
              &lt;/div&gt;
              &lt;div class="col-md-6"&gt;
                  {{ article.title }}
              &lt;/div&gt;
          &lt;/div&gt;
          {% endfor %}
      &lt;/div&gt;
      {% if is_paginated %}
      &lt;section id="content-btn"&gt;
          &lt;div id="load-more-btn blippar-white-btn" class="col-md-2 col-md-offset-5 col-xs-8 col-xs-offset-2" align="center"&gt;
                  &lt;a id="loadmore" role="button" class="button btn load-more-btn blippar-white-btn" href="{{ load_more_url }}"&gt;{% trans 'VIEW MORE' %}&lt;/a&gt;
          &lt;/div&gt;
      &lt;/section&gt;
  
      &lt;div class="col-lg-12"&gt;
  
          &lt;span class="current"&gt;
              Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.
          &lt;/span&gt;
  
          {% if page_obj.has_next %}
              &lt;a href="?page={{ page_obj.next_page_number }}"&gt;next&lt;/a&gt;
          {% endif %}
  
      &lt;/div&gt;
  
      {% endif %}
  {% endif %}
  </code></pre>
  
  <p>So, I have 2 questions :</p>
  
  <ol>
  <li>Why isn't it showing on the main articles-list ?</li>
  <li>Why, after selecting a source, if I click on "next" all my items are displayed ?</li>
  </ol>
  
  <p>If you have an idea or an reflexion orientation, I would love it :)</p>