Home > Software design >  How would I write this regular expression url pattern with path in django?
How would I write this regular expression url pattern with path in django?

Time:08-02

I am following a beginner django tutorial and my django version is set up to use path instead of the url and I am unsure how to write this code using path:

url(r'^?P<album_id>[0-9] ', views.detail())

CodePudding user response:

Here are docs for path converters https://docs.djangoproject.com/en/4.0/topics/http/urls/#path-converters. In your case it would be

path('<int:album_id>', views.detail)

CodePudding user response:

from django.urls import path from . import views

path('product/<int:pk>/', views.product),
path('home/', views.dashboard), 
  • Related