The Django tutorial explains how to create a basic poll app. The templates in the tutorial frequently use hard-coded URL structures—for instance:
<form action="/polls/{{ poll.id }}/vote/" method="post">
And:
<a href="/polls/{{ poll.id }}/">Vote again?</a>
What would be the best way to refactor this code to avoid repeating /polls/ throughout the templates?
Use the
urltemplate tag https://docs.djangoproject.com/en/1.4/ref/templates/builtins/#url