Opened 7 years ago

Closed 7 years ago

#29231 closed Bug (fixed)

Documentation Regression for Tutorial 03

Reported by: Paul Owned by: nobody
Component: Documentation Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

It looks like this issue may have been fixed in the past, but documentation version 1.7 onward do not mention this. It is also not mentioned in Tutorial 04.
The tutorial is missing a reference to adding the namespace to the mysite/urls.py as follows:

from django.contrib import admin
from django.urls import path, include

 urlpatterns = [
-    path('polls/', include('polls.urls')),
+    path('polls/', include('polls.urls', namespace="polls")),
     path('admin/', admin.site.urls),
 ]

Without this change, it gives an NoReverseMatch error, "polls" is not a registered namespace

Could the tutorial be updated to include this change?
https://docs.djangoproject.com/en/2.0/intro/tutorial03/#namespacing-url-names

Change History (5)

comment:1 by Tim Graham, 7 years ago

Resolution: invalid
Status: newclosed

This suggestion is incorrect. You may be missing app_name = 'polls' in polls/urls.py.

comment:2 by Paul, 7 years ago

Resolution: invalid
Status: closednew

Here is my polls/url.py:

from django.urls import path

from . import views

app_name = 'polls'
urlpatterns = [
        # /polls/
        path('',views.index, name='index'),
        # /polls/5/
        path('<int:question_id>/', views.detail, name='detail'),
        # /polls/5/results/
        path('<int:question_id>/results/', views.results, name='results'),
        # /polls/5/vote/
        path('<int:question_id>/vote/', views.vote, name='vote'),
]

And python -m django --version yields 2.0.3

comment:3 by Paul, 7 years ago

Running in virtualenv, pip list -l:
arrow (0.12.1)
blessed (1.14.2)
Django (2.0.3)
django-picklefield (1.0.0)
django-q (0.9.4)
pip (9.0.1)
python-dateutil (2.7.0)
pytz (2018.3)
setuptools (38.5.2)
six (1.11.0)
uWSGI (2.0.17)
wcwidth (0.1.7)
wheel (0.30.0)

comment:5 by Paul, 7 years ago

Resolution: fixed
Status: newclosed

Not sure what's going on, but it's working now following the existing tutorial steps.

Note: See TracTickets for help on using tickets.
Back to Top