2016-01-20 169 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

工程就像一個魅力!謝謝。 –