Я новичок в Джанго. Я хочу перенаправить URL в подробный вид, но путь в urls.py не работает.
это urls.py
from django.urls import path, include
from basic_app import views
app_name = 'basic_app'
urlpatterns = [
path('', views.SchoolListView.as_view(), name='list'),
path('<school.id>', views.SchoolDetailView.as_view(),name='detail'),
]
это мои views.py
from django.shortcuts import render
from django.views.generic import (View, TemplateView,
DetailView, ListView)
from . import models
class IndexView(TemplateView):
template_name = 'index.html'
class SchoolListView(ListView):
context_object_name = 'schools'
model = models.School
class SchoolDetailView(DetailView):
context_object_name = 'school_detail'
model = models.School
template_name = 'basic_app/school_detail.html'
это мой school_list.html
{% extends 'basic_app/basic_app_base.html' %}
{% block title %}
<title> School List Page </title>
{% endblock title %}
{% block content %}
<h1> Welcome to the list of schools </h1>
<ol>
{% for school in schools %}
<h3><li><a href="{{school.id}}">{{school.name}}</a></li></h3>
{% endfor %}
</ol>
{% endblock content %}
это мой school_detail.html
{% extends 'basic_app/basic_app_base.html' %}
{% block title %}
<title> School Details Page </title>
{% endblock title %}
{% block content %}
<h1> Welcome to the Details of schools </h1>
<h2> School Details </h2>
<p>Name: {{school_detail.name}} </p>
<p>Principal: {{school_detail.principal}} </p>
<p>Location: {{school_detail.location}} </p>
<h2> Students: </h2>
{% for student in school_detail.students.all %}
<p> {{student.name}} who is {{student.age}} years old </p>
{% endfor %}
{% endblock content %}
Я хочу перенаправить ссылку в подробный вид школы.