In the previous lesson, you set up the routes that directed your request all the way to your views.py file. You got an error telling you that this views doesn’t actually exist. Now, you need to create a view.
Go to views.py, where you already have some imports as well as a helpful message to create your views here. Create your new function, project_list():
# Create your views here.
def project_list(request):
pass
Now you’ve got a new error message that you can use to fix your function!
Martin Breuss RP Team on Sept. 23, 2020
Hi @iwatts and thanks for noting this. I just went to double-check and having the
/in your empty path does prevent it from loading correctly, both on Django 3 as well as Django 2.2.16, so there’s no change regarding the Django version, but it just doesn’t work.So let’s explore this a bit more :)
Reproducing the Error
I gave it a spin with a small contrived example project, where I set the
urlpatternslike so:And here’s the error message that Django sent me as a response when trying to access the base URL at
http://127.0.0.1:8000/as well ashttp://127.0.0.1:8000:Django’s feedback in this case is maybe slightly confusing, but it’s really all in there. :) Django is telling us that it looked at the two existing path configurations,
/andadmin/, but that The empty path didn’t match any of these.The Empty Path
When you go to a URL, such as
http://127.0.0.1:8000/, the/at the end isn’t a text part of the URL. Instead it has the meaning that it separates URL path components.Django knows that and strips these off, and doesn’t consider them as part of a path component that you are defining in your
path()calls.Which means that if you type
http://127.0.0.1:8000/, Django receives as a string component to process further only the stuff that comes after the final/. In this case, that is nothing, or rather, an empty string''.A Hacky Experiment
So what would you need to do in order to match a path configuration that looks like this:
What URL would you need to type into your browser to make Django match it? Give it a try and report back here :)