diff --git a/songs/templates/songs/index.html b/songs/templates/songs/index.html index db97d03..0ff0d2c 100644 --- a/songs/templates/songs/index.html +++ b/songs/templates/songs/index.html @@ -4,7 +4,18 @@ {% block content %}

Songs

- + {% include 'components/song-table.html' with songs=page_obj %} + {% endblock %} \ No newline at end of file diff --git a/songs/views.py b/songs/views.py index 0057f69..56b61d9 100644 --- a/songs/views.py +++ b/songs/views.py @@ -1,10 +1,14 @@ +from django.core.paginator import Paginator from django.shortcuts import render, redirect from .models import Song # Create your views here. def song_index(request): songs = Song.objects.all() - return render(request,'songs/index.html',{'songs':songs}) + paginator = Paginator(songs, 100) + page_number = request.GET.get('page',1) + page_obj = paginator.get_page(page_number) + return render(request,'songs/index.html',{'page_obj':page_obj}) def song_id(request, id): song = Song.objects.filter(id=id)[0]