0

Hi I am new to Django programming

please find my program which is not working.I am not getting any error though.

 urlpatterns = [
    url(r'departmentlist/',views.DepartmentList.as_view(),name='departmentlist'),
    url(r'^departmentlist/(?P<pk>\d+)$',views.DepartmentDetail.as_view(),name='departmentdetail'),
 ]

But when I am passing the '(?P<pk>\d+)$' alone it is working...Can any one help me.

Mahmood Afzalzadeh
  • 180
  • 1
  • 2
  • 20
  • actual urls,py is the following. url(r'departmentlist/',views.DepartmentList.as_view(),name='departmentlist'), url(r'^departmentlist/(?P\d+)$',views.DepartmentDetail.as_view(),name='departmentdetail'), after saving the question the was getting vanished – Arundhathi Feb 16 '19 at 11:37

2 Answers2

0

You didn't terminate the pattern for the list view.

url(r'^departmentlist/$',views.DepartmentList.as_view(),name='departmentlist'),
Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
0

You can edit the URL to:

url(r'^departmentlist/(?P<pk>[\d+])$',views.DepartmentDetail.as_view(),name='departmentdetail'),
]
Mahmood Afzalzadeh
  • 180
  • 1
  • 2
  • 20
Sanip
  • 1,772
  • 1
  • 14
  • 29
  • 1
    Thank you for your suggestion.I could figure out the issue.I have written the rgx for departmentlist first so , it was comparing that first and got a match and stopped.so it did not go to the next comparison(departmentlist/). – Arundhathi Feb 17 '19 at 05:34