On part 3 of the tutorial, I got down to “Removing hardcoded URLs in templates”. I tried changing the name of the polls detail view to “custom”, but when I tried accessing the server using /custom, I got the following error:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/polls/custom/
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
polls/ [name='index']
polls/ custom/<int:question_id>/ [name='custom']
polls/ <int:question_id>/results/ [name='results']
polls/ <int:question_id>/vote/ [name='vote']
admin/
The current path, polls/custom/, didn’t match any of these.
I did some troubleshooting and ended up changing the function name for the view in views.py, but it didn’t resolve the error. I then changed a few other things (I can’t remember what exactly), it still didn’t work, then I ended up changing “custom” back to the original “detail”. However, now I get a different error when trying to access the server:
# Page not found (404)
|Request Method:|GET|
| --- | --- |
|Request URL:|http://127.0.0.1:8000/|
Using the URLconf defined in `mysite.urls`, Django tried these URL patterns, in this order:
1. polls/
2. admin/
The empty path didn’t match any of these.
Clearly I’m missing something, or I unwittingly edited something while troubleshooting that has broken access to the entire server.
The full description is at Removing hardcoded URLs in templates. Briefly, it’s exactly what the title describes, you’re removing full hard-coded urls from your templates. It does not change the urls themselves.
That depends upon whether you’re using a version control system like git, or if your editor / IDE maintains file history, or if your editor’s undo function tracks these recent changes back far enough.