[Django] #35165: Django Tutorial - Writing Your First App

11 views
Skip to first unread message

Django

unread,
Feb 4, 2024, 1:29:48 PM2/4/24
to django-...@googlegroups.com
#35165: Django Tutorial - Writing Your First App
-----------------------------------------+------------------------
Reporter: maddiew1se | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 5.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
Hello,

I just recently completed the Django Tutorial - Writing Your First App.
When I try to do http://127.0.0.1:8000/admin/polls/1/ I get a 404 Page Not
Found Error. I followed all of the steps in the tutorial but it appears
that my detail view is not working. Whenever I try and click on a
question, it immediately sends me to the /change/ url. What should I do
about this? I will attach my polls.urls.py file. from django.urls import
path

from . import views


app_name = 'polls'
urlpatterns = [
path('', views.IndexView.as_view(), name='index'),
path('<int:pk>/', views.DetailView.as_view(), name='detail'),
path('<int:pk>/results/', views.ResultsView.as_view(),
name='results'),
path('<int:question_id>/vote/', views.vote, name='vote'),
]
and here is my views.py for the detail view:

class DetailView(generic.DetailView):
model = Question
template_name = 'polls/detail.html'

def get_queryset(self):
"""
Excludes any questions that aren't published yet.
"""
return Question.objects.filter(pub_date__lte=timezone.now())
--
Ticket URL: <https://code.djangoproject.com/ticket/35165>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 4, 2024, 2:02:52 PM2/4/24
to django-...@googlegroups.com
#35165: Django Tutorial - Writing Your First App
-------------------------------+--------------------------------------
Reporter: maddiew1se | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 5.0
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 Tim Graham):

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


Old description:

> Hello,
>
> I just recently completed the Django Tutorial - Writing Your First App.
> When I try to do http://127.0.0.1:8000/admin/polls/1/ I get a 404 Page
> Not Found Error. I followed all of the steps in the tutorial but it
> appears that my detail view is not working. Whenever I try and click on a
> question, it immediately sends me to the /change/ url. What should I do
> about this? I will attach my polls.urls.py file. from django.urls import
> path
>
> from . import views
>

> app_name = 'polls'
> urlpatterns = [
> path('', views.IndexView.as_view(), name='index'),
> path('<int:pk>/', views.DetailView.as_view(), name='detail'),
> path('<int:pk>/results/', views.ResultsView.as_view(),
> name='results'),
> path('<int:question_id>/vote/', views.vote, name='vote'),
> ]
> and here is my views.py for the detail view:
>
> class DetailView(generic.DetailView):
> model = Question
> template_name = 'polls/detail.html'
>
> def get_queryset(self):
> """
> Excludes any questions that aren't published yet.
> """
> return Question.objects.filter(pub_date__lte=timezone.now())

New description:

Hello,

I just recently completed the Django Tutorial - Writing Your First App.
When I try to do http://127.0.0.1:8000/admin/polls/1/ I get a 404 Page Not
Found Error. I followed all of the steps in the tutorial but it appears
that my detail view is not working. Whenever I try and click on a
question, it immediately sends me to the /change/ url. What should I do
about this? I will attach my polls.urls.py file.

{{{#!python


from django.urls import path
from . import views


app_name = 'polls'
urlpatterns = [
path('', views.IndexView.as_view(), name='index'),
path('<int:pk>/', views.DetailView.as_view(), name='detail'),
path('<int:pk>/results/', views.ResultsView.as_view(),
name='results'),
path('<int:question_id>/vote/', views.vote, name='vote'),
]
}}}
and here is my views.py for the detail view:

{{{#!python


class DetailView(generic.DetailView):
model = Question
template_name = 'polls/detail.html'

def get_queryset(self):
"""
Excludes any questions that aren't published yet.
"""
return Question.objects.filter(pub_date__lte=timezone.now())
}}}

--
Comment:

This is a bug tracker. See TicketClosingReasons/UseSupportChannels for
ways to get help.
--
Ticket URL: <https://code.djangoproject.com/ticket/35165#comment:1>

Reply all
Reply to author
Forward
0 new messages