Page 3

27 views
Skip to first unread message

rbarh...@gmail.com

unread,
Aug 27, 2020, 8:07:38 PM8/27/20
to Django users
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.py
from 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 12
    path('<int:question_id>/results/'), views.results, name='results'),
```
I cannot see the error.  Please help.  Thank you.

rbarh...@gmail.com

unread,
Aug 27, 2020, 8:12:53 PM8/27/20
to Django users
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 helped

rbarh...@gmail.com

unread,
Aug 28, 2020, 5:32:05 PM8/28/20
to Django users
The error message claims invalid syntax and point to the equal sign between name and 'results.'

RANGA BHARATH JINKA

unread,
Aug 28, 2020, 9:56:25 PM8/28/20
to django...@googlegroups.com
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 👍

--
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...@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.

rbarh...@gmail.com

unread,
Aug 29, 2020, 5:29:51 PM8/29/20
to Django users
Hmm.  I don't understand what you are saying.

rbarh...@gmail.com

unread,
Aug 29, 2020, 5:35:31 PM8/29/20
to Django users
In the above problem example, this statement does not seem to work:
```
from django.urls import path
```
why not

Kunal Solanke

unread,
Aug 29, 2020, 11:04:31 PM8/29/20
to django...@googlegroups.com
he is saying about the ")" read what you wrote slowly...........

Kunal Solanke

unread,
Aug 29, 2020, 11:05:37 PM8/29/20
to django...@googlegroups.com
And yes plz don't ever paste code like this  .Either use pastebin or take screen shots of pc not by phone.

rbarh...@gmail.com

unread,
Aug 30, 2020, 2:09:34 PM8/30/20
to Django users
I posted this from my computer and used the three ticks instructed by Ken Whitesell.  You instruction is way off base.  I don't post anything from a cell phone.  You have too wonder about people who sermonize.

rbarh...@gmail.com

unread,
Aug 30, 2020, 2:15:19 PM8/30/20
to Django users
And by the way, thanks for the clarification.  In spite of the other stuff, I read through the code and found the error and I appreciate it.  Multiple instructions on the same issue are frustrating.
Reply all
Reply to author
Forward
0 new messages