【发布时间】:2016-04-26 16:26:58
【问题描述】:
我刚开始使用 django/web 开发,但遇到了问题。在我的模板文件夹中,我有 base.html、home.html 和 licenses.html 模板。在 home.html 我有一个链接 <li><a href="{% url 'licences' %}">Licences</a></li> 在我的 views.py 我有方法 licences(request):
def licences(request):
return render(request, "licences.html", {})
但是,如果我随后运行服务器并单击链接,我会得到一个仅显示 base.html 元素的空白页面。
如何解决此问题以显示新页面?
编辑:
urls.py
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$', 'searchFilm.views.home', name='home'),
url(r'^results/$', 'searchFilm.views.results', name='results'),
url(r'^licences/$', 'searchFilm.views.licences', name='licences')
]
licences.html
<html>
<head>
<!-- <title>{% block title %}HomePage{% endblock %}</title> -->
</head>
<body>
<p>This page contians informations on the licences</p>
</body>
</html>
【问题讨论】:
-
您的
urls.py文件是什么样的? -
嗨,我已经更新了我的问题
-
licences.html模板是什么样的? -
嗨,我又更新了我的问题
-
请同时包含base.html