I'm new to Django and I'm trying to create a simple path to later link it to the database, for now: I created this URL path in my music app:
urlpatterns = [
# /music/
path('', views.index, name='index'),
# /music/*****/
path(r'^(?P<album_id>[0-9]+)/$', views.detail, name='detail'),
]
And I added this to the views.py:
def detail(request, album_id):
return HttpResponse("<h2>Details for Album id: " + str(album_id) + "</h2>")
But it doesn't work, every time I ask for this url: http://localhost:8000/music/2 I got "Page not found"
Please help. Thanks.
We can use django path converts for your use case. So, please change
to
Reference: https://learnbatta.com/blog/custom-path-converters-in-django-17/