0

I made a searchbar for my website, my database is getting quite big now so I wanted to add pagination system, but if I click the buttons I made it shows me the text that I want to show when nothing is typed in.

code:

def search_album(request):
    if request.method == 'POST':
        searched = request.POST.get('searched')
        p = Paginator(Album.objects.filter(title__contains=searched), 20)
        page = request.GET.get('page')
        albums = p.get_page(page)
        return render(request, 'home/search_album.html', {'searched':searched, 'album':albums })
    else:
        return render(request, 'home/search_album.html')
NART
  • 1
  • 1

0 Answers0