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.
* 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>
* keywords: example error =>
* resolution: fixed => invalid
* easy: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/33249#comment:2>