Randy Tang
Randy Tang

Reputation: 4353

Django templates: tags in tags

In Django templates, I am trying to have a tag within another tag:

The project's urls.py:

url(r'^lists/', include('lists.urls', namespace='lists')),

The lists app's 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 %}

It doesn't seem to work. The result of home.html is

<form method="POST" action=" url 'lists:newList' ">

instead of what I want:

<form method="POST" action="/lists/new/">

Upvotes: 0

Views: 91

Answers (1)

Anoop
Anoop

Reputation: 2798

I think this will work

base.html

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

home.html

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

Upvotes: 1

Related Questions