You are using the new syntax to define URLs from Django 2.0 with the old 
urls() method.

If you are using Django 2.0, polls/urls.py should look like this:

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'),
]

If you are using an earlier version of Django, it should look like this:

from django.conf.urls import url

from . import views

urlpatterns = [
    # ex: /polls/
    url(r'^$', views.index, name='index'),
    # ex: /polls/5/
    url(r'^(?P<question_id>[0-9]+)/$', views.detail, name='detail'),
    # ex: /polls/5/results/
    url(r'^(?P<question_id>[0-9]+)/results/$', views.results, 
name='results'),
    # ex: /polls/5/vote/
    url(r'^(?P<question_id>[0-9]+)/vote/$', views.vote, name='vote'),
]

Notice the difference? Use from django.conf.urls.url with the old regular 
expression syntax and django.urls.path with the new angle bracket syntax.

Cheers,
Daniel

On Wednesday, January 24, 2018 at 6:58:49 AM UTC+1, anookeen wrote:
>
>
>
> *This is the screenshot for mysite/urls.py*
>
>
>
>
> *This is the screenshot for mysite/polls/urls.py*
> *This is screenshot for mysite/polls/views.py*
>
>
>
>
>
> *Screenshot of error*
>
>
>
>>
>>
>>
>
> On Tuesday, January 23, 2018 at 7:13:00 PM UTC, anookeen wrote:
>>
>> Hi , I am creating django app mentioned at this link 
>> (https://docs.djangoproject.com/en/2.0/intro/tutorial02/). When I create 
>> new views and add that into urls.py , the new urls aren't recognized (such 
>> as it doesn't recognize the question_id mentioned in part 3 of the 
>> tutorial). Kindly help me out. Thanks in advance.
>>
>
11

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ba7db96d-1682-40e9-a680-af1d1c376e2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to