Answers for "django url slug int"

C
2

slug urls django

path('<slug:slug>,<int:id>/', views.article_detail, name='article'),
Posted by: Guest on May-31-2020
4

django slug int url mapping

# in views define the int slugs then the url mapping is like this

from django.urls import path, re_path

from . import views

urlpatterns = [
    path('articles/2003/', views.special_case_2003),
    re_path(r'^articles/(?P<year>[0-9]{4})/$', views.year_archive),
    re_path(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/$', views.month_archive),
    re_path(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<slug>[\w-]+)/$', views.article_detail),
]
Posted by: Guest on November-09-2020

Code answers related to "C"

Browse Popular Code Answers by Language