Hi,
You are closing the para thesis before.
path('<int:question_id>/results/', views.results, name='results'),
This is the correct syntax. All the best 👍
The error message claims invalid syntax and point to the equal sign between name and 'results.'--On Thursday, August 27, 2020 at 5:12:53 PM UTC-7 rbarh...@gmail.com wrote:My code inspector tells me that "from django.urls import path" is unused so the path statements must not work, I guess. But the tutorials presents that code.BTW, it's Maxim who helpedOn Thursday, August 27, 2020 at 5:07:38 PM UTC-7 rbarh...@gmail.com wrote:Thanks to Maxi, I could move on and immediately found a new problem on Part 3.I have studied this error message for over an hour and cannot figure it out. Here is the code. There are two pieces, one in polls/views.py and one in polls/urls.py.```polls/views.pyfrom django.http import HttpResponse
# Create your views here.
def index(request):
return HttpResponse("I have a BIG present for you.")
def detail(request, question_id):
return HttpResponse("You are looking at question %s." % question_id)
def results(request, question_id):
response = "You are looking at the results of question %s."
return HttpResponse(response % question_id)
def vote(request, question_id):
return HttpResponse("You are voting on question %s." %
question_id)```urls.py;```from django.urls import path
from . import views
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'),
]```produces this error message:```File "/Users/reb/Desktop/PycharmProjects/081920/djangoProject0/mysite/polls/urls.py", line 12path('<int:question_id>/results/'), views.results, name='results'),```I cannot see the error. Please help. Thank you.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/75c28487-1d92-4488-a9b7-b3e7a8cc2bc5n%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK5m317kf8-QBwAsCNUMSpMAdQuy5cHUi8OM-HbD3LFcECEO%2BA%40mail.gmail.com.
No comments:
Post a Comment