当我从一个页面切换到另一个页面时,除了教师页面之外什么也没发生 从老师页面我不能去任何其他页面!
<ul class="sidebar-menu" data-widget="tree">
<li class="treeview">
<a href="Dashboard:index">
<i class="fa fa-dashboard"></i>
<span>Current Courses</span>
</a>
</li>
<li class="treeview">
<a href="Dashboard:result">
<i class="fa fa-th"></i>
<span>All Batch Records</span>
</a>
</li>
<li class="treeview">
<a href="{% url 'Dashboard:course' %}">
<i class="fa fa-list"></i>
<span>Courses</span>
</a>
</li>
<li>
<a href="{% url 'Dashboard:teacher' %}">
<i class="fa fa-user"></i>
<span>Teachers</span>
</a>
</li>
</ul>
我的 urls.py 文件:
from django.urls import path
from . import views
app_name = 'Dashboard'
urlpatterns = [
path('', views.IndexView.as_view(), name='index'),
path('course/', views.course, name='course'),
path('teacher/', views.teacher, name='teacher'),
path('student/', views.student, name='student'),
path('result/', views.result, name='result'),
]
当我从一个页面切换到另一个页面时,除了教师页面之外什么也没发生 从老师页面我不能去任何其他页面!
你应该使用 url 模板标签
<a href="{% url 'Dashboard:index' %}">
和 相同
<a href="{% url 'Dashboard:result' %}">
您没有在模板中调用正确的 URL: 它应该像下面这样:
<ul class="sidebar-menu" data-widget="tree">
<li class="treeview">
<a href="{% url 'Dashboard:index' %}">
<i class="fa fa-dashboard"></i> <span>Index</span>
</a>
</li>
<li class="treeview">
<a href="{% url 'Dashboard:course' %}">
<i class="fa fa-th"></i> <span>Courses</span>
</a>
</li>
<li class="treeview">
<a href="{% url 'Dashboard:student' %}">
<i class="fa fa-list"></i><span>Students</span>
</a>
</li>
<li>
<a href="{% url 'Dashboard:result' %}">
<i class="fa fa-user"></i> <span>Results</span>
</a>
</li>
<li>
<a href="{% url 'Dashboard:teacher' %}">
<i class="fa fa-user"></i> <span>Teachers</span>
</a>
</li>
</ul>