【发布时间】:2016-09-05 21:49:29
【问题描述】:
我目前正在对 admin/index.html 模板进行更改,我需要在我的应用程序中使用 href 标记中的名称空间 'hello' 来引用 URL 以获得链接,但我在管理员级别。我的应用程序的名称是干净的,并且 urls.py 文件中的 url 模式如下。
urls.py
from django.conf.urls import url, include
from . import views
urlpatterns = [
url(r'^HelloWorld/$', views.hello, name='hello'),
]
我试图避免在 admin/index.html 中对下面的 href 标记进行硬编码。任何建议都会有很大帮助
<div>
<h3>Hello World</h3>
<a href="http://127.0.0.1:8000/clean/HelloWorld">Test</a>
</div>
【问题讨论】:
-
你为什么不用
{% url %}标签?