Hi, I’m completely new to Django and am trying to do the tutorial so I can use it with my students next year. I want to use Replit as it gives us a completely Web based environment (our students to not have access to decent desktops).
I’ve created a Replit using the Django template on the site. I’ve then followed the instructions in the tutorial to start creating the Polls app. Unfortunately I’ve fallen over at the first hurdle. I’ve created the exact set of files and made the changes in the tutorial but when I run it I get the 404 page that says the empty path does not match:
The issue seems to be with the include function.
In the top level urls.py file I have the following:
from django.contrib import admin
from django.urls import include, path
from polls import views
urlpatterns = [
path("admin/", admin.site.urls),
path("polls/", include("polls.urls")),
]
In the url.py in the polls folder I have this:
from django.urls import path
from polls import views
urlpatterns = [
path(“”, views.index, name=“index”),
]
This does not work. If I move the path(“”, views.index, name=“index”), statement from the url.py file in polls to the url.py in the top level url.py it works as expected. It is as if the urlpattern from poll.url is not being picked up.
I’ve been trying to fix this for hours and have done lots of googling and not been able to find a solution. I can work round it by just defining my urls in the top file but I’d like to be able to do it as per the tutorial.
Apologies if I have not posted this correctly as this is the first time I’ve used this forum