S
S
s_katala2018-05-23 20:07:35
Django
s_katala, 2018-05-23 20:07:35

How to load content on scroll?

Tell me how to implement content loading when scrolling the page!
django2

paginator

{% if is_paginated %}
          {% if page_obj.has_previous %}
            <a href="?page={{ page_obj.previous_page_number }}">&laquo;</a>
          {% else %}
          {% endif %} 
          {% for i in paginator.page_range %} 
            {% if page_obj.number == i %}
              {{ i }}
            {% endif %}
          {% endfor %}
          {% if page_obj.has_next %}
            <a href="?page={{ page_obj.next_page_number }}">&raquo;</a>
          {% else %}
          {% endif %}
        {% endif %}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-05-23
@s_katala

First, you need to write a javascript code that will handle the scroll event, calculate the required page, make a request to the server, and display the data received from the server. Secondly, you need to write a view that, in response to an ajax request, will return json with the necessary data. The code added to the question will not be useful to you in this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question