I am following the tutorial, and it is not working no matter what I try. I am at the end of the 1st part of the tutorial, but every time I try running http://127.0.0.1:8000/polls it just does not work and says admin is the only URL that shows. I have tried many fixes from other posts, but it is not working.
mysite/mysite/urls has the code from the tutorial, and i filled out polls/views and polls/urls. I have deleted all my files and restarted the tutorial a few times, but it is not working. Here is the code I have:
polls/views.py:
Create your views here.
from django.http import HttpResponse
def index(request):
return HttpResponse(“Hello, world. You’re at the polls index.”)
polls/urls.py:
from django.urls import path
from . import views
urlpatterns = [
path(“”, views.index, name=“index”),
]
my site urls:
from django.contrib import admin
from django.urls import include, path
Your url path includes the trailing slash for the url polls/, but you aren’t showing it in the url that you’re saying that you are trying. Yes, polls and polls/ are two different urls.
Sorry that was unclear, I have tried polls/ as well, but neither seem to work, and when on the 404 error page it only says that admin/ is a URL present it does not even show polls
I’ve to say I’m pretty intrigued about that error. I just did that first section of the tutorial on two UNIX machines, and they both worked. Unfortunately, I don’t have a Windows machine at hand right now.
Can you put that code on a public repository and share the link?
Wow this is weird, but I just tried the same thing on my computer without adding the polls app in the INSTALLED_APPS in the settings.py and this is working
It’s a configuration setting, it doesn’t “automatically “ do that. So without diving into those settings, I don’t assume it’s going to be there. See Settings | Django documentation | Django
Oh my god. The issue was that the files I was typing was not properly saving when I hit control S, so when I put it to git it just pushed empty files. All the code I typed was not saved that’s why nothing was working.
Oh man I just want to thank you for taking the time to post that you have no idea how much you have helped me i have been going crazy for 5 hours not knowing why none of my code was running turns out I wasnt saving anything lmao hadnt even thought of that until I read you comment