2016-01-20 301 views
0

在Django模板标签,我想有另一个标签内的标签: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/"> 

回答

1

我认为这会工作

base.html文件

<form method="POST" action="{% block url %}{% endblock %}"> 
... 
</form> 

home.html的

{% block url %} {% url 'lists:newList' %} {% endblock %} 
+0

工程就像一个魅力!谢谢。 –