Firstly, I apologize as I know this portion of the tutorial has been asked about many times. I am only asking as I have not been able to find a solution that works for me.
I am on the first part of the “Getting Started Tutorial” but I am unable to access the polls index or the admin page.
I have triple checked that my “urls.py” files are in the correct place.
/mysite/mysite/urls.py
and
/mysite/polls/urls.py
respectively.
I have also checked that there are no other urls.py in the directory. Only “mysite” “polls” “db.sqlite3” and “manage.py” are in my “mysite” root directory.
When using the server, I restart the server every time I make changes. I have checked both
http://127.0.0.1:8000/polls/
and
http://127.0.0.1:8000/admin/
Each of these links gives me a “Can’t reach this page: 127.0.0.1 refused to connect”
I also checked using just the http://127.0.0.1:8000/ adress, which gave me an expected 404 error, and showed both “admin/” and “polls/” listed as searched for URLs.
From my looking through forums, I found someone who had the exact issue as myself, with the same setup, however for them, adding “polls/” to the end of their URL took them to the correct destination, but for me it does not. I am at a loss as to what I am doing wrong at this point. I’ll include the code I am using below. Please let me know if there is any more info you need from me regarding what I am doing. If it matters, I am doing this in a Github codespace, rather than locally.
mysite/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),
]
mysite/polls/urls.py
from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="index")
]
mysite/polls/views.py
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world. You're at the polls index.")