ruk·si

🍡 Django Tutorial
Add URL Namespaces

Updated at 2018-11-23 18:26

When you start having multiple apps in a project, you need to namespace your resource addresses so the URL helpers work right.

Add the following to polls/urls.py:

# ...
app_name = 'polls'
urlpatterns = [
    # ...
]

Edit polls/templates/polls/index.html:

# ...
        <li>
            <a href="{% url 'polls:detail' question.id %}">{{ question.text }}</a>
        </li>
# ...