URL

Django URLs

  • name
  • Namespace
  • App Name

Name

name is a name of URL pattern.

url(r'^$', views.IndexView.as_view(), name='index')

From views

reverse('index')

From templates

{% url 'index' %}

Namespace

namespace is a namespace in the project specified in urls.py on including app side

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

From views

reverse('polls:index')

From templates

{% url 'polls:index' %}

App Name

app_name is a namespace in the project specified in urls.py on the included app side

app_name = 'polls'
urlpatterns = [
    url(r'^polls/', include('polls.urls')),  # 'namespace="polls"' removed
...
]

From views

reverse('polls:index')

From templates

{% url 'polls:index' %}