My Paginator not working at the last page button

when click next and previous button is working, but the last page not working

class VenueForm(ModelForm):
    class Meta:
        model = Venue
        fields = (
            'name', 'address', 'zip_code', 'phone', 'web', 'email_address'
        labels = {
            'name': '',
            'address': '',
            'zip_code': '',
            'phone': '',
            'web': '',
            'email_address': '',
        widgets = {
            'name': forms.TextInput(attrs={
                'class': 'form-control', 'placeholder': 'Venue Name'}),
            'address': forms.TextInput(attrs={
                'class': 'form-control', 'placeholder': 'Address'}),
            'zip_code': forms.TextInput(attrs={
                'class': 'form-control', 'placeholder': 'Zip Code'}),
            'phone': forms.TextInput(attrs={
                'class': 'form-control', 'placeholder': 'Phone'}),
            'web': forms.TextInput(attrs={
                'class': 'form-control', 'placeholder': 'Web'}),
            'email_address': forms.EmailInput(
                attrs={'class': 'form-control', 'placeholder': 'Email'}),

from .models import Event, Venue
from django.core.paginator import Paginator

def list_venues(request):
    venue_list = Venue.objects.all()
    p = Paginator(Venue.objects.all(), 3)
    page = request.GET.get('page')
    venues = p.get_page(page)
    nums = "a" * venues.paginator.num_pages
    return render(request, 'events/venue.html', {
        'venue_list': venue_list, 'venues': venues, 'nums': nums})


<nav aria-label="Page navigation example">
  <ul class="pagination justify-content-center">
    {% if venues.has_previous %}
    <li class="page-item">
      <a class="page-link" href="?page=1">&laquo; First</a>
    <li class="page-item">
      <a class="page-link" href="?page={{ venues.previous_page_number }}">Previous</a>
    {% endif %}
    {% for i in nums %}
    <li class="page-item">
      <a class="page-link" href="?page={{ forloop.counter }}">{{ forloop.counter }} </a>
    {% endfor %}
    {% if venues.has_next %}
    <li class="page-item">
      <a class="page-link" href="?page={{ venues.next_page_number }}">Next</a>
    <li class="page-item">
      <a class="page-link" href="?page={{ venues.paginator.num_pages ))">Last &raquo;</a>
    {% endif %}

i don't know why, every create a question it show me red ! to me (It looks like your post is mostly code; please add some more details) and i always use long time to pass it

Back to Top