I am trying to create a dynamic list of urls based on a list of pages.
In my urls.py, the whole application is behind the namespace base:
urlpatterns = patterns('',
url(r'^(?P<pk>[\w]+)/title/$', TitleSection.as_view(), name='title'),
url(r'^(?P<pk>[\w]+)/amount/$', AmountSection.as_view(), name='amount'),
url(r'^(?P<pk>[\w]+)/description/$', DescriptionSection.as_view(), name='description'), )
And in my contextdata, I have the following list:
sections: ['title', 'amount', 'description']
I am trying to create urls for each element in sections.
I tried the following:
{% for section in sections %}
<a href="{% url "base:"+section pk=object.id %}">..</a>
{% endfor %}
But I got the following error:
Failed to parse the remainder: '+ section' from '"base:" + section'
Then I tried:
<a href="{% url "base:{{section}}" pk=project.id %}">{{ section }}</a>
Error:
The converse for '{{section}}' with the arguments' () 'and the keyword arguments' {u'pk': 77} 'was not found. 0 samples (s): []
Do you know how to do this?