i am using python 3.8 and getting error when i launch server:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/
Using the URLconf defined in djangoProject.urls, Django tried these URL patterns, in this order:
polls/
admin/
The empty path didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
my polls/urls.py:
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]
my djangoProject/urls.py:
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url("polls/", include('polls.urls')),
url("admin/", admin.site.urls),
]
The root urls contains two items: polls/
and admin/
. This thus means that if you visit the root URL (127.0.0.1:8000/
), it will not trigger any view, since no view has been "attached" to that URL pattern. You thus will have visit a page to trigger the view, or change the URL patterns to enable visiting the index
view if you visit the root URL.
/polls/
You can visit the page by visiting:
127.0.0.1:8000/polls/
index
to the root URLYou can change the URL patterns to trigger index
when visiting the root URL with:
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
# ↓↓ empty string
url('', include('polls.urls')),
url('admin/', admin.site.urls),
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With