Project1: "Entry Page: Visiting /wiki/TITLE, where TITLE is the title of an encyclopedia entry, should render a page that displays the contents of that encyclopedia entry."

I am having difficulty making it so that when write into the url with a different TITLE, I bring up the same page, but with response inside the page. When we did the example from lecture with hello/NAME, we added into views.py:

def greet(request, name):
    return HttpResponse(f"Hello, {name}!")

Then in urls.py:

urlpatterns = [
    path('admin/', admin.site.urls),
    path("<str:name>", views.greet, name="greet")

so that the NAME is variable depending on "<str:name>"

Now, I've aimed to do the similar thing for Project1 [and eventually add more functionality] I've added into the folder 'wiki' a views.py with:

from django.http import HttpResponse
from django.shortcuts import render

# should be just a template page, then insert the MD inside of it
def greet(request, name):
    return HttpResponse(f"Hello, {name}!")

And into the urls.py in wiki/ I've added

from django.contrib import admin
from django.urls import include, path

from . import views

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include("encyclopedia.urls")),
    path("<str:name>", views.greet, name="greet"),

I'm getting the following error when I open something like wiki/cat

Page not found (404)
Request Method: GET
Request URL:
Using the URLconf defined in wiki.urls, Django tried these URL patterns, in this order:

<str:name> [name='greet']
The current path, wiki/cat, didn’t match any of these.

You must log in to answer this question.

Browse other questions tagged .