Dynamic URL with variable django template
<p>I'm trying to build a dynamic list of urls, based on a list of pages.</p>

<p>In my urls.py, the whole application is behind the namespace <code>base</code>:</p>

<pre><code>urlpatterns = patterns('',
    url(r'^(?P&lt;pk&gt;[\w]+)/title/$', TitleSection.as_view(), name='title'),
    url(r'^(?P&lt;pk&gt;[\w]+)/amount/$', AmountSection.as_view(), name='amount'),
    url(r'^(?P&lt;pk&gt;[\w]+)/description/$', DescriptionSection.as_view(), name='description'), )
</code></pre>

<p>And in my <code>context</code> data I have the following list:</p>

<pre><code>sections: ['title', 'amount', 'description']
</code></pre>

<p>I am trying to build the urls for each of the element in the sections.</p>

<p>I tried the following:</p>

<pre><code>{% for section in sections %}
    &lt;a href="{% url "base:"+section pk=object.id %}"&gt;..&lt;/a&gt;
{% endfor %}
</code></pre>

<p>But I got the following error:</p>

<blockquote>
  <p>Could not parse the remainder: '+section' from '"base:"+section'</p>
</blockquote>

<p>Then I tried:</p>

<pre><code>&lt;a href="{% url "base:{{section}}" pk=project.id %}"&gt;{{ section }}&lt;/a&gt;
</code></pre>

<p>Error:</p>

<blockquote>
  <p>Reverse for '{{section}}' with arguments '()' and keyword arguments '{u'pk': 77}' not found. 0 pattern(s) tried: []</p>
</blockquote>

<p>Do you know how to do this?</p>