Issue
Reverse for 'update' with keyword arguments '{'pk': ''}' not found. 1 pattern(s) tried: ['basic_app/update/(?P[0-9]+)/\Z']
9 <p>Location: {{school_detail.location}} </p>
10 <h3>Students:</h3>
11 {% for student in school_detail.students.all %}
12 <p>{{student.name}} who is {{student.age}} years old</p>
13 {% endfor %}
14
15
16 </div>
17
18 <div class="container">
19 <p><a class='btn btn-warning' href="{% url 'basic_app:update' pk=school_details.pk %}">Update</a></p>
20
21 </div>
22 {% endblock %}
Here is urls.py
from django.urls import path
from basic_app import views
app_name='basic_app'
urlpatterns = [
path('',views.SchoolListView.as_view(),name='list'),
path('<int:pk>/',views.SchoolDetailView.as_view(),name='detail'),
path('create/',views.SchoolCreateView.as_view(),name='create'),
path('update/<int:pk>/',views.SchoolUpdateView.as_view(),name='update'),
]
Solution
Typo:
{% url 'basic_app:update' pk=school_details.pk %}
Should be:
{% url 'basic_app:update' pk=school_detail.pk %}
Answered By - Lewis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.