[Django] #33249: Writing your first Django app, part 3, Initial Path missing '/'

5 views
Skip to first unread message

Django

unread,
Oct 31, 2021, 7:46:12 AM10/31/21
to django-...@googlegroups.com
#33249: Writing your first Django app, part 3, Initial Path missing '/'
-----------------------------------------+-------------------------------
Reporter: Eric Jonathan | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 3.2
Severity: Normal | Keywords: example error
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-----------------------------------------+-------------------------------
O/S: Windows 10
Python Version 3.10.0
Django 3.2.8

Following the tutorial at the "Writing your first Django app, part 3"
(https://docs.djangoproject.com/en/3.2/intro/tutorial03/),
at the:
poll/urls.py
example, currently, it's


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

With error:
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/polls/6/
Using the URLconf defined in mysite.urls, Django tried these URL patterns,
in this order:

polls [name='index']
polls <int:question_id>/ [name='detail']
polls <int:question_id>/results/ [name='results']
polls <int:question_id>/vote/ [name='vote']
admin/
The current path, polls/6/, didn’t match any of these.

You’re seeing this error because you have DEBUG = True in your Django
settings file. Change that to False, and Django will display a standard
404 page.

It should be:

{{{
urlpatterns = [
path('', views.index, name='index'),
path('/<int:question_id>/', views.detail, name='detail'),
path('/<int:question_id>/results/', views.results, name='results'),
path('/<int:question_id>/vote/', views.vote, name='vote'),
]
}}}

With result:

You're looking at question 6.

--
Ticket URL: <https://code.djangoproject.com/ticket/33249>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 31, 2021, 7:50:06 AM10/31/21
to django-...@googlegroups.com
#33249: Writing your first Django app, part 3, Initial Path missing '/'
-------------------------------+--------------------------------------

Reporter: Eric Jonathan | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: 3.2
Severity: Normal | Resolution: fixed

Keywords: example error | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Eric Jonathan):

* status: new => closed
* resolution: => fixed


Comment:

When I did mysite/urls.py,

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

I missed the '/' on the polls,

polls
instead of
polls/

--
Ticket URL: <https://code.djangoproject.com/ticket/33249#comment:1>

Django

unread,
Oct 31, 2021, 9:16:54 AM10/31/21
to django-...@googlegroups.com
#33249: Writing your first Django app, part 3, Initial Path missing '/'
-------------------------------+--------------------------------------

Reporter: Eric Jonathan | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: 3.2
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Jacob Walls):

* keywords: example error =>
* resolution: fixed => invalid
* easy: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/33249#comment:2>

Reply all
Reply to author
Forward
0 new messages