Opened 5 years ago
Closed 5 years ago
#31554 closed Cleanup/optimization (invalid)
Tutorial 01: mysite/urls.py location confusion
Reported by: | Paweł Brodacki | Owned by: | Desmond Nyamador |
---|---|---|---|
Component: | Documentation | Version: | 2.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
Hi guys,
Working through the 2.2 tutorial I got momentarily stuck at
Go to http://localhost:8000/polls/ in your browser, and you should see the text “Hello, world. You’re at the polls index.”, which you defined in the index view.
What I got was a 404. Debug information of the built-in web server indicated that it wasn't aware of the polls/
path. Copy-paste of .py code from the tutorial to the editor didn't help.
The issue was I created urls.py
in the outer (/somepath/mysite/
), and not the inner (/somepath/mysite/mysite
) mysite directory. Once I understood what the problem was, the web server error message made sense, which was nice ;)
Documentation is consistent, in a sense that it tells the reader to create urls.py as polls/urls.py
and then as mysite/urls.py
, so it can be concluded that the author meant mysite/polls
and mysite/mysite
, respectively. However, the fact, that django uses the same directory name at two levels is a trap for newbies.
I would like to propose two possible fixes to this issue:
- After the contents of mysite/urls.py file add Your mysite directory should now look like:(…) followed by the directory listing, similarly to how polls/ directory content is shown earlier in the tutorial.
- Add 'If you see
Not Found: /polls/
error message in the server output then there's a problem with your mysite/urls.py file. Make sure you edited the file in the inner mysite directory (at the same filesystem level as the polls directory). , or similar text to the "Page not found" help inset.
Any of them should help the stray reader.
Other versions of the tutorial (I checked 3.0 and dev) use the same wording and might benefit from the change.
Change History (7)
comment:1 by , 5 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
follow-up: 3 comment:2 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Version: | 3.0 → 2.2 |
comment:3 by , 5 years ago
Replying to Desmond Nyamador:
Hi, I've gone through the documentation and it says at a point "To create a URLconf in the polls directory, create a file called urls.py. Your app directory should now look like:". I believe specifying the word "app" says it all.
Hi,
Once you know it says all, it does. However, before you do, it may be not obvious.
If you google for django tutorial 404
you'll find the proof that people are misreading the tutorial instructions. Unless it's an intended effect, calculated to make the reader pay attention, I believe it would be nice if people didn't have to go to Stack Overflow to get past the tutorial.
Your call :)
comment:4 by , 5 years ago
Has patch: | unset |
---|---|
Resolution: | fixed → invalid |
Summary: | tutorial 01: mysite/urls.py location confusion → Tutorial 01: mysite/urls.py location confusion |
Tutorial is really descriptive, we ask to add urls.py
in app directory. Moreover all expected files are listed below:
polls/ __init__.py admin.py apps.py migrations/ __init__.py models.py tests.py urls.py views.py
comment:5 by , 5 years ago
Resolution: | invalid |
---|---|
Status: | closed → new |
comment:6 by , 5 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:7 by , 5 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Triage Stage: | Accepted → Unreviewed |
Desmond, please don't reopen invalid tickets.
Hi, I've gone through the documentation and it says at a point "To create a URLconf in the polls directory, create a file called urls.py. Your app directory should now look like:". I believe specifying the word "app" says it all.