Not redirecting to correct template
So I am practicing django cbvs and I am using update veiw to update model data and I created a button which is suppose to redirect to the form to update but it is showing me the same template page with jst url updated and id infront of it. I have django 1.11.25 installed currently heres my app url and views and the details page:
urls:
from django.conf.urls import url
from Cbvs_app import views
app_name = 'Cbvs_app'
urlpatterns = [
url(r'^$',views.School_List.as_view(),name='list'),
url(r'(?P<pk>\d+)/$',views.School_Detail.as_view(),name='details'), # it simply grabs the primary key provided in href and displays corresponding detail view to the primary key
url(r'^create/$',views.School_Create.as_view(),name='create'),
# print("Registering SchoolUpdateView URL"),
url(r'^update/(?P<pk>\d+)/$',views.SchoolUpdateView.as_view(),name='update'),
]
Views:
class School_Create(CreateView): # my create view is working fine
fields = ('name','principal','location')
model = models.School
template_name = "Cbvs_app/school_form.html"
class SchoolUpdateView(UpdateView):
fields = ("name","principal")
model = models.School
template_name = "Cbvs_app/school_form.html"
forms:
{% extends "Cbvs_app/Cbvs_app_basic.html" %}
{% block body_block %}
<div class="jumbotron">
<h1>Welcome to detail of all schools</h1>
<h2>School details: </h2>
<p>Name: {{school_detail.name }}</p>
<p>Principal: {{school_detail.principal }}</p>
<p>Location: {{school_detail.location }}</p>
<p>Students:</p>
{% for student in school_detail.students.all %}
<p>{{student.name}} who is {{student.age}} years old.</p>
{% endfor %}
<p>Id: {{school_detail.pk}}</p>
<p><a class='btn btn-warning' href="{% url 'Cbvs_app:update' pk=school_detail.pk %}">Update</a></p>
</div>
{% endblock %}
I tried to print in the console but the printing statments threw error i also tried changing the html file names but it didnt affect i also tried adding template_name variable. if you have any suggestions regarding or documentation please answer or leave a comment