Python Django html重定向但不';t加载页面

Python Django html重定向但不';t加载页面,python,html,django,django-urls,Python,Html,Django,Django Urls,我正在创建一个Django web应用程序,遇到了以下问题 我创建了一个名为teamList.html的新html页面,当单击主页上的a href超链接时,该页面应重定向到teamList页面。浏览器中的url,以http://127.0.0.1:8000/更改为http://127.0.0.1:8000/teamList,但下面的页面不会更改,而是重新加载起始页面 当前应用程序处理html中的登录和主页(登录后默认显示图形): 编辑:My views.py用于My teamList.html的

我正在创建一个Django web应用程序,遇到了以下问题

我创建了一个名为teamList.html的新html页面,当单击主页上的a href超链接时,该页面应重定向到teamList页面。浏览器中的url,以
http://127.0.0.1:8000/
更改为
http://127.0.0.1:8000/teamList
,但下面的页面不会更改,而是重新加载起始页面

当前应用程序处理html中的登录和主页(登录后默认显示图形):

编辑:My views.py用于My teamList.html的方法如下所示:

from django.conf.urls import patterns, url
from myApp import views

urlpatterns = patterns('',
#http://localhost:8000/             
url(r'^$', views.index, name='index'),
url(r'^/teamList/$', views.renderTeamList, name='teamList')
)
from django.shortcuts import render
from django.views.generic.base import TemplateView
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from myApp.models import FocusArea
from myApp.tables import TeamTable
from django_tables2 import RequestConfig

def renderTeamList(request):
table = TeamTable()
RequestConfig(request).configure(table)
return render(request, 'teamList.html', {'table': table})

除了注释之外,您的
url.py也有问题。
teamList
url的正则表达式以
/
开头,因此将不匹配
http://127.0.0.1:8000/teamList
默认情况下,Django会替换前导斜杠。从文档中:

不需要添加前导斜杠,因为每个URL都有前导斜杠。例如,它是^articles,而不是^articles


有关更多详细信息,请参阅。

您的看法如何?这就是您要重定向的位置。视图返回是否正确。?
from django.shortcuts import render
from django.views.generic.base import TemplateView
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from myApp.models import FocusArea
from myApp.tables import TeamTable
from django_tables2 import RequestConfig

def renderTeamList(request):
table = TeamTable()
RequestConfig(request).configure(table)
return render(request, 'teamList.html', {'table': table})