Altessimo/categories/views.py

23 lines
859 B
Python
Raw Normal View History

2020-12-15 21:32:20 +00:00
from django.shortcuts import render
from django.http import HttpResponse
2020-12-16 17:36:29 +00:00
from .models import Branch, Category
from songs.models import Song
from artists.models import Artist
2020-12-15 21:32:20 +00:00
# Create your views here.
2020-12-16 17:36:29 +00:00
def category_index(request):
categories = Category.objects.all()
return render(request,"categories/index.html",{'categories':categories})
def category_show(request, slug):
category = Category.objects.filter(slug=slug)[0]
return render(request,"categories/show.html",{'category':category})
def branch_index(request):
branches = Branch.objects.all()
return render(request,"branches/index.html",{'branches':branches})
def branch_show(request, acronym):
branch = Branch.objects.filter(acronym=acronym)[0]
songs = Song.objects.filter(branch=branch)
return render(request,"branches/show.html",{'branch':branch,'songs':songs})