Monday, 4 March 2019

django 9 render views

#music/views

from django.shortcuts import render
from django.http import  HttpResponse
from .models import Album
from django.shortcuts import render

def index(request):
    all_albums = Album.objects.all()
    context = {
        'all_albums': all_albums,
    }
    return render(request, 'music/index.html', context)

def detail(request, album_id):
    return HttpResponse('<h2>Details for Album id: ' + str(album_id) + '</h2>')

No comments:

Post a Comment