I’m new to Django and am trying to create the back end code for a music application on my website.
I have created the correct view in my views.py file (in the correct directory) as shown below:
def detail(request, album_id): return HttpResponse("<h1>Details for Album ID:" + str(album_id) + "</h1>")
however, when creating the url or path for this (shown below)
#/music/71/ (pk) path(r'^(?P<album_id>[0-9])/$', views.detail, name='detail'),
I am experiencing a warning on my terminal stating:
?: (2_0.W001) Your URL pattern '^(?P<album_id>[0-9])/$' [name='detail'] has a route that contains '(?P<', begins with a '^', or ends with a '$'. This was likely an oversight when migrating to django.urls.path().
and whenever the
/music/ (for which the path works) is followed by a number, such as
/music/1 (which is what I want to be able to do) the page cannot be found and the terminal gives the above warning.
It may be a simple error and just me being stupid but I’m new to Django and python regex statements, so any help is appreciated.