Can you try this in your views.py?

from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator

views.py

feedTextAll = feedText.objects.order_by('-feedTexDate')
pages = Paginator(feedTextAll,5)
pageNum = request.GET.get('page')
feedtext = pages.get_page(pageNum)
return render(request, 'index.html',{'feedtext':feedtext})


and then in your html file where you want to show paginated records

{% for feedtext in feedtext%}

<!--- Display your records here--!>

{% endfor %}




<!--- displaying page numbers at bottom --!>

<ul class="pagination justify-content-center" style="margin:20px 0">

          {% if feedtext.has_previous %}
            <li class="page-item"><a class="page-link"
href="?page=1"><<</a></li>
            <li class="page-item"><a class="page-link"
href="?page={{feedtext.previous_page_number}}"><</a></li>
          {%else%}
            <li class="page-item disabled"><a class="page-link"
href="#"><<</a></li>
            <li class="page-item disabled"><a class="page-link"
href="#"><</a></li>
          {% endif %}
          {%for num in feedtext.paginator.page_range %}
          {% if feedtext.number == num %}
            <li class="page-item text-bold active"><a class="page-link"
href="?page={{num}}">{{num}}</a></li>
          {%endif%}
          {% endfor %}
          {% if feedtext.has_next %}
            <li class="page-item"><a class="page-link"
href="?page={{feedtext.next_page_number}}">></a></li>
            <li class="page-item"><a class="page-link"
href="?page={{feedtext.paginator.num_pages}}">>></a></li>
          {%else%}
            <li class="page-item disabled"><a class="page-link"
href="#">></a></li>
            <li class="page-item disabled"><a class="page-link"
href="#">>></a></li>
          {%endif%}

      </ul>


On Tue, Feb 19, 2019 at 12:21 PM Aakash Baranwal <baakash1...@gmail.com>
wrote:

> First image is of the Views.py which is in the API folder and second
> Views.py is for the project as you will notice in the images.
>
> On Tue, Feb 19, 2019 at 11:41 AM Siddharth Tamang <
> tamangsiddhart...@gmail.com> wrote:
>
>> Please send your views.py. You must have a home page or index page where
>> you want to paginate records.
>>
>> On Tue, Feb 19, 2019 at 11:23 AM Aakash Baranwal <baakash1...@gmail.com>
>> wrote:
>>
>>> I have also used Ajax with that. It's load more button is not working,
>>> it is showing the 10 posts which is the limit I set in the beginning, but
>>> not going beyond that.
>>>
>>> On Tue, Feb 19, 2019 at 11:13 AM Siddharth Tamang <
>>> tamangsiddhart...@gmail.com> wrote:
>>>
>>>> Are you trying pagination using JavaScript or Django?
>>>>
>>>> On Mon, Feb 18, 2019 at 11:47 PM Aakash Baranwal <baakash1...@gmail.com>
>>>> wrote:
>>>>
>>>>> Hello Everyone,
>>>>>
>>>>> I am new to Django and working towards developing a web app where 10
>>>>> posts appear at a time with a "Load More" option given at last which when
>>>>> clicked shows the next 10 posts. I am not able to find what is going wrong
>>>>> with the code.
>>>>>
>>>>> Also, it is not showing the character counter for the textbox, so
>>>>> kindly help me with that as well.
>>>>>
>>>>> I am sending the screenshot of the code, pagination.py file.
>>>>>
>>>>> Thank You in advance
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Django users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>>> To post to this group, send email to django-users@googlegroups.com.
>>>>> Visit this group at https://groups.google.com/group/django-users.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/django-users/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/django-users/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>>> --
>>>> Thank you
>>>> Siddharth Tamang
>>>> AWS Certified Solutions Architect - Associate
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>> To post to this group, send email to django-users@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/django-users.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/django-users/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CALr9hQ1CRSweCoycg0AfyiwG9LFb%3DZ2NL7oW7BMPuBg8qk%2B2GA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CALr9hQ1CRSweCoycg0AfyiwG9LFb%3DZ2NL7oW7BMPuBg8qk%2B2GA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>> Thank you
>> Siddharth Tamang
>> AWS Certified Solutions Architect - Associate
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CADBOudtmJpskP-K_5%3D24BOXExeNq0%3DreM4nQZbWLaVrJVo0k8Q%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CADBOudtmJpskP-K_5%3D24BOXExeNq0%3DreM4nQZbWLaVrJVo0k8Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALr9hQ2%2Brp-ih4YCS34PYw3nxFwvvT-EG0DqAdbJ4taLunDHYQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALr9hQ2%2Brp-ih4YCS34PYw3nxFwvvT-EG0DqAdbJ4taLunDHYQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Thank you
Siddharth Tamang
AWS Certified Solutions Architect - Associate

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADBOudtwS0Eddgq6o-KP8rdU-5%3D2LvcDub%3DF-dUg3kczJ3pXyA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to