【发布时间】:2016-01-20 04:30:58
【问题描述】:
在 Django 模板中,我试图在另一个标签中添加一个标签:
项目的urls.py:
url(r'^lists/', include('lists.urls', namespace='lists')),
lists 应用程序的urls.py:
url(r'^new/$', views.newList, name='newList'),
url(r'^(?P<listID>[0-9]+)/$', views.viewList, name='viewList'),
base.html:
<form method="POST" action="{% {% block url %}{% endblock %} %}">
...
</form>
home.html:
{% block url %} url 'lists:newList' {% endblock %}
list.html:
{% block url %} url 'lists:viewList' {{list.id}} {% endblock %}
它似乎不起作用。 home.html 的结果是
<form method="POST" action=" url 'lists:newList' ">
而不是我想要的:
<form method="POST" action="/lists/new/">
【问题讨论】: