Saturday, 2 March 2019

django 7 url/id?

#music/urls

from django.urls import path
from . import views

urlpatterns = [
    path('', views.index, name='index'),

    #/music/id/
    path('<album_id>/', views.detail, name='detail'),
]

-------------------------------
#musics/views

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

def index(request):
    return HttpResponse('<h1>music app homepage</h1>')

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

No comments:

Post a Comment