Decapelo
Decapelo

Reputation: 1

Django polls app is not working as expctected in the tutorial for me

I am getting this error every time restart my server

Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/polls/

Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: admin/ The current path, polls/, didn't match any of these.

I have tried restarting the server but the same error is popping up every time.

polls/urls.py

from django.urls import path

from . import views

urlpatterns = [

    path('', views.index, name = 'index'),

]

mysite/urls.py

from django.contrib import admin

from django.urls import include, path

urlpatterns = [

    path("polls/", include("polls.urls")),

    path("admin/", admin.site.urls)

]

views.py/polls

from django.http import HttpResponse


def index(request):

    return HttpResponse("Hello world. You're at the polls index.")

The expected result as per the Django tutorial is the text "Hello world. You're at the polls index." after you start your server

Upvotes: 0

Views: 247

Answers (1)

Oliver Sandoval
Oliver Sandoval

Reputation: 11

You probably didn't add your app polls to installed apps in your settings.py.

Open your file settings.py and write:

INSTALLED_APPS = [
...., 
'polls',

]

Upvotes: 1

Related Questions