Like many others I am having problems with part 1 of the tutorial. I get the message at the end of part 1 which says
Page not found (404)
|Using the URLconf defined in
mysite.urls, Django tried these URL patterns, in this order:
The current path,
polls/, didn’t match any of these.
I am amazed that I am seeing so many new users having this same problem, and this is not directly addressed in the tutorial itself. There are many wild and crazy ideas on the source of the problem and the potential fixes, including editing the code in VS code.
The problems seem to lie in mysite/urls.py and mysite/polls/urls.py so I have copied the contents of these two files here.
from django.urls import include, path
urlpatterns = [
from . import views
urlpatterns = [
path("", views.index, name="index"),
OS: Linux Mint 20.3
Any assistance appreciated. Maybe we can improve the documentation for beginners to reduce the number who simply move on to others systems.
Actually, the causes of this varies, because there are a number of different mistakes that can be made that result in this error.
One of the common errors is when someone is in the “inner”
mysite directory when they run
startapp instead of the “outer”
In other words, the directory structure should look like this:
And yes, this is documented in the tutorial. It’s covered in the two paragraphs in the Creating the Polls app section after the “Projects vs apps” note box.
Many thanks for your response. I went to check the directory structure and confirmed that both the mysite and polls directories were in the outer mysite directory.
Another file to verify location is that the urls.py files are in
Your image implies that you’ve got a urls.py file in the outer mysite directory when it should be in the inner mysite.
Yes it wasn’t clear from the tutorial whether the urls.py file should be in the mysite or the mysite/mysite directory.
I checked my file layout -
but it doesn’t seem to have fixed the problem. I made sure I cleared the cache on my browser (firefox) that doesn’t seem to have changed anything.
Is there complete code for the first part of the tutorial on github or elsewhere? This would solve a lot of problems.
Thank you. Tutorial part 1 is now working.
Can I suggest the following improvements to the documentation:
- Inset section/place numbers in the documentation so that it is easier to refer to a particular spot.
- In the location of the urls.py files, these should be:
The latter should not be referred to a mysite/urls.py as this is misleading. If there was any numbering system, I would refer to the particular spot.