Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django 2.0 Trying to Grab the primary key with regular Expressions but im getting 404

Tags:

python

django

This is my Code ..

urlpatterns =[
path('',views.School_Lview.as_view(),name='list'),
path('(?P<pk>\d+)/',views.School_Dview.as_view(),name='detail')
]

I am trying to get this template to work

{% for school in schools %}
<h2><li><a href="{{school.id}}"> {{school.name}}</a></li></h2>
{% endfor%}
like image 782
AbrarWali Avatar asked Nov 04 '25 22:11

AbrarWali


1 Answers

I Fixed it...I used re_path instead of path and it worked like a charm..

re_path('(?P<pk>\d+)/',views.School_Dview.as_view(),name='detail')
like image 159
AbrarWali Avatar answered Nov 06 '25 12:11

AbrarWali



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!