Altessimo/songs/views.py

15 lines
490 B
Python
Raw Normal View History

2020-12-16 17:36:29 +00:00
from django.shortcuts import render, redirect
2020-12-15 21:32:20 +00:00
2020-12-16 17:36:29 +00:00
from .models import Song
2020-12-15 21:32:20 +00:00
# Create your views here.
2020-12-16 17:36:29 +00:00
def song_index(request):
songs = Song.objects.all()
return render(request,'songs/index.html',{'songs':songs})
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})