1
0
mirror of https://github.com/Damillora/Altessimo synced 2024-11-24 22:57:32 +00:00
Altessimo/songs/views.py
2020-12-17 00:51:29 +07:00

19 lines
669 B
Python

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()
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]
return redirect(song_show,id=song.id,title=song.title)
def song_show(request, id, title):
song = Song.objects.filter(id=id,title=title)[0]
return render(request,'songs/show.html',{'song':song})