Error message:
Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/music/2/ Using the URLconf defined in Analytic_practice.urls, Django tried these URL patterns, in this order:
admin/ music/ [name='index'] music/ (?P<album_id>[0-9]+)/ [name='detail'] The current path, music/2/, didn't match any of these.
Here is my code:
music.urls.py file:
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('(?P<album_id>[0-9]+)/', views.detail, name='detail'),
]
views.py:
from django.http import HttpResponse
# noinspection PyUnusedLocal
def index(request):
return HttpResponse("<h1>This will be a list of all Albums</h1>")
# noinspection PyUnusedLocal
def detail(request, album_id):
return HttpResponse("<h2>Details for Album id: " + str(album_id) + "</h2>")
Analytic_practice.urls.py:
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('admin/', admin.site.urls),
path('music/', include('music.urls')),
]