Complete six-part pre-release for review. Build two placeholder pages, trace their routes, and check them with Django tests.
Milestone reached in this chapter: First Otahque page. Django answers a request with a page written for Otahque. All milestones
CHAPTER NINE
URLs and routing
Stage 2: Pages and design (Chapters 9 to 14)
Prerequisites: Chapters 3, 6, 7, and 8, and the Chapter 8 project checkpoint
What you’ll build: a local Otahque home page and an event-list placeholder, each reached through a URL and checked with an automated test written first.
Why This Matters
Soni is deciding whether to attend a workshop, and one day she will type an Otahque address to find out. On our computer, that address leads nowhere useful yet. The browser can reach Django’s welcome page, but it cannot show an Otahque home page or an event list. The events app exists, and the project has its settings and dependencies, but we have not told Django which code should answer either address.
An address is useful only when the application knows what to do with it. A URL is an address that identifies a resource on the web. In Chapter 3 we followed a request from a browser to a server and back. Now we will look at one step inside Django: routing, the process of matching the requested path to code that can produce a response. A view is the code Django calls to handle that request. For now, our views will return short pieces of text so we can see the route working.
This chapter also changes how we work. Until now, we checked each result by looking at it. From here on, we first write down what the application should do as an automated test, watch that test fail, and then write the code that makes it pass.
Figure 9.1 — A request follows a route to a view, and a response returns to the browser.
By the end of the chapter, you will be able to:
identify the path in a URL and explain how Django uses it to choose a view;
connect project and app URL configurations so each owns a clear part of the routing;
create named routes for a home page and an event-list placeholder;
write a test first, read its failure, and make it pass with Django’s test client;
recognize an unmatched address and investigate common routing mistakes.
The event list in this chapter is a placeholder, not a list of saved or published events. We will explore views and request and response objects in Chapter 10, build HTML templates in Chapter 11, and add styling in Chapters 13 and 14. Models and stored event data come later. The wider milestone of browsable, styled event pages is not complete at the end of this chapter.
In Chapter 3 we saw that a browser uses an address to find a server and ask for a resource. Consider http://127.0.0.1:8000/events/?page=2. The scheme http describes the protocol, 127.0.0.1 names the local computer, and 8000 is the port. The path is /events/. The query string begins after ?; here it carries page=2. A fragment after #, if present, is used by the browser and is not sent as part of the HTTP request.
Django’s URL patterns normally match the request path, not the host or query string. The leading slash is not written in a path() route. For example, /events/ is represented by events/. The home address / corresponds to an empty route, ''. A trailing slash is a character in the route: use the exact addresses shown in this chapter. A redirect for a missing slash depends on settings and middleware; do not rely on it as a substitute for the right route.
Que. 1 Does /events/?page=2 need a different route from /events/?page=3?
Flip to check your answerFold answer back
Answer. No. Both have the same path, /events/; the query strings differ. A view may later choose to read those values, but the URL pattern does not match them.
The route and the view
New Concept: URL configuration
What problem exists? Our project needs to choose the right code for each requested path.
What did people do before? A program could compare paths by hand and call a different function for each one, as The Custom Way shows in How We Build It.
What is a URL configuration? A URL configuration, often called a URLconf, is a Python module containing Django’s URL patterns.
Why a URLconf? Django’s path() and include() let us describe and organize those patterns without writing the dispatcher ourselves.
Now let’s use it.
Each path() connects a route to a view or another URLconf. Our root URLconf is config/urls.py, selected by ROOT_URLCONF in the settings. The project will keep Django’s existing admin route and include events/urls.py for Otahque’s own routes. The app URLconf will name its routes home and list, inside an events namespace. A namespace is a prefix that distinguishes one app’s route names from another’s: events:home means the home name belonging to events.
include() passes the remaining path to the included patterns after the prefix matches. We will include our app at the empty prefix, so the app will match both the empty home route and events/. Chapter 7 left one decision for this chapter: where the home page lives. For now its view sits in the events app, because finding events is all the home page offers so far; if it later draws on several apps, we will move it and record why. Including an app at the root does not mean it must own every future page. The project can include other apps at other prefixes as they arrive. Figure 9.2 shows the two files we will end up with, and how a request for /events/ passes through them.
Figure 9.2 — Two URLconfs share the work: the project delegates, and the app names its own routes.
Under the Hood: Choosing a view
Django begins with the root URLconf and tries its patterns in order. A matching include() leads to another set of patterns, which are also tried in order. A matching view is called with the request and any values captured by the route. If no complete route matches, Django returns a 404 response. Earlier broad patterns can hide later matches, so route order deserves attention. A 404 can also be raised by view code; the status alone does not identify the cause.
The view returns an HttpResponse object. That object contains the response sent back for the request. Our two responses are deliberately simple text; a view does not have to be a template or a database query. Chapter 10 will examine requests and responses more closely.
Names work in the other direction
Routing usually starts with a path and finds a view. reverse() starts with a route name and finds its path. For example, after we add the routes, reverse('events:list') returns /events/. A stable name can keep other code from repeating a path, although renaming the route or changing required arguments still requires updating callers. Later, templates will use the same idea to build links.
In practice: a mistyped address
Situation. Later, Soni mistypes the address of a workshop she is reading about.
Application. Django finds no matching route and returns a 404, which tells her that the requested resource was not found. While developing, compare the actual path with the patterns in both files, and check the spelling and slashes before changing any code.
Consideration. The detailed debug page you see locally is a development aid, not a public error page. Chapter 8 keeps debug mode off everywhere else.
Que. 2 Which file decides that an events/ request reaches the event-list view in our planned configuration?
Flip to check your answerFold answer back
Answer. Both URLconfs participate. config/urls.py includes the events URLconf at the empty prefix; events/urls.py maps the remaining events/ path to the view.
Tests that run without a browser
New Tool: Django’s test client
What problem exists? Checking pages by hand is slow, and it is easy to forget a page that a later change has broken.
What did people do before? Someone clicked through the site after each change, or nobody did.
What is the test client? A tool that sends simulated requests through Django’s URLs, middleware, and views without starting a server or a browser, then hands the response to your test.
Why the test client? It comes with Django and runs quickly, so we can repeat the whole check after every change. It does not show how a browser displays a page, so we keep the browser check too.
Now let’s use it.
A test is a method whose name starts with test, inside a class. We will use SimpleTestCase, Django’s test class for tests that do not touch a database, because no database is involved yet. We run the tests with manage.py test. It reports each test with one character: . when the test passed, F when an assertion failed, and E when the test stopped with an unexpected error.
Writing a test first has a practical benefit beyond tidiness. A test you have seen fail is a test you know can fail. A test written after the code might pass for the wrong reason, and you would never find out.
Start with the Chapter 8 project in the folder containing manage.py, its locked environment, and your own local .env. We will replace events/tests.py and events/views.py, create events/urls.py, and replace config/urls.py. We will not add packages, models, or migrations. The visible result is two text pages on the local development server, three passing tests, and a second Git commit.
The Custom Way
Imagine a small dispatcher with two comparisons. This is an illustration only; do not add it to the project. It has no HTTP server and does not replace Django.
illustration_only/choose.py (not part of the project)
def choose(path):
if path == '/':
return 'home'
if path == '/events/':
return 'event list'
return 'not found'
The idea is useful, but a real dispatcher must cooperate with requests, responses, nested routes, errors, and middleware. Django already supplies that machinery. We describe our routes instead.
The Django Way
Step 1: Write the tests first
Decide what the finished routes should do, and write it down as tests. Replace the contents of events/tests.py with this complete file:
events/tests.py
"""Tests for the events app."""
from django.test import SimpleTestCase
from django.urls import resolve, reverse
from . import views
class RoutingTests(SimpleTestCase):
"""Each address reaches its view; others are not found."""
def test_home(self):
response = self.client.get('/')
self.assertEqual(response.status_code, 200)
self.assertContains(
response, 'Welcome to Otahque.'
)
self.assertEqual(reverse('events:home'), '/')
self.assertIs(resolve('/').func, views.home)
def test_event_list(self):
response = self.client.get('/events/')
self.assertEqual(response.status_code, 200)
self.assertContains(
response, 'Event list coming soon.'
)
self.assertEqual(reverse('events:list'), '/events/')
self.assertIs(
resolve('/events/').func, views.event_list
)
def test_unknown_path(self):
response = self.client.get('/does-not-exist/')
self.assertEqual(response.status_code, 404)
self.client.get() sends a simulated GET request. assertContains checks a useful part of the response as well as its status. reverse() asks for the path belonging to a name; resolve() asks Django which view a path selects; and assertIs checks that the selected function is the same function we intended. Now run the tests. In PowerShell, a macOS shell, or Linux/WSL Bash, beside manage.py:
Terminal
uv run python manage.py test events
Expected result, shortened with ... where lines are left out:
Output
Found 3 test(s).
System check identified no issues (0 silenced).
FF.
...
FAIL: test_event_list (events.tests.RoutingTests...
...
AssertionError: 404 != 200
...
FAIL: test_home (events.tests.RoutingTests.test_home)
...
AssertionError: 404 != 200
...
Ran 3 tests in ...
FAILED (failures=2)
Read this from the top. FF. means that two tests failed and one passed, in alphabetical order. Each FAIL block names the test and the assertion that stopped it, and 404 != 200 says that the response was 404 where the test wanted 200. That is correct: no routes exist yet. The unknown-path test already passes, because every path is unknown so far. It will start to mean something once real routes exist beside it. Leave the tests failing and continue. The elapsed time varies, and the system check and the summary can appear in a different order because they use separate output streams.
Step 2: Write the two views
Open events/views.py. Replace its generated contents with this complete file. A function receives the request; each returns a response with distinct text.
events/views.py
"""The events app's views: one function per page."""
from django.http import HttpResponse
def home(request):
"""Welcome visitors to Otahque."""
return HttpResponse('Welcome to Otahque.')
def event_list(request):
"""List Otahque's events."""
return HttpResponse('Event list coming soon.')
Step 3: Add the app URLconf
Common Error: calling the view too soon
Use views.home, not views.home(). Parentheses call the function while the URLconf is loading, before Django has supplied a request, and every command then stops with TypeError: home() missing 1 required positional argument: 'request'.
Create events/urls.py beside views.py. The first argument of path() is the route, the second is the view function itself, and name gives the route a reusable name. We pass the functions without parentheses; Django calls them when a request matches.
events/urls.py
"""Addresses of the events app's pages."""
from django.urls import path
from . import views
app_name = 'events'
urlpatterns = [
path('', views.home, name='home'),
path('events/', views.event_list, name='list'),
]
Step 4: Include the app in the project
Replace config/urls.py with the complete file below. The empty prefix delegates paths to the events app. The names config/urls.py and events/urls.py refer to two different files.
config/urls.py
"""URL configuration for the Otahque project."""
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('events.urls')),
]
Run the system check and the tests again, in any of the three shells:
Terminal
uv run python manage.py check
uv run python manage.py test events
Expected result, shortened; the dashed line is left out:
Output
System check identified no issues (0 silenced).
Found 3 test(s).
System check identified no issues (0 silenced).
...
Ran 3 tests in ...
OK
The three dots mean three passing tests, and no test database was created, because SimpleTestCase does not use one. The tests that failed in Step 1 now pass, and we saw them fail for the reason we expected.
Step 5: Visit the pages
The tests do not prove that a browser displays the pages, so look at them as well. In the same folder, start the local development server:
Terminal
uv run python manage.py runserver
Open http://127.0.0.1:8000/, where the page reads Welcome to Otahque. Then open http://127.0.0.1:8000/events/, where it reads Event list coming soon. If the first address still shows Django’s rocket and “The install worked successfully!”, then config/urls.py does not yet include the app. Now open http://127.0.0.1:8000/does-not-exist/ and observe a 404 page. With local debug mode enabled, Django shows diagnostic information; its appearance is not the production error page. Stop the server with Ctrl+C. A warning about unapplied migrations is expected at this checkpoint; do not run migrations yet.
When something goes wrong
Table 9.1 lists the problems these steps can produce. Each recovery corrects one file; none of them replaces your work.
Table 9.1 — Routing problems and safe recovery
Symptom
Likely cause
What to check
ModuleNotFoundError: No module named 'events.urls'
events/urls.py is missing or has another name
Check that the file is inside events/ and is named urls.py
/ still shows The install worked successfully!, and /events/ is 404
config/urls.py does not include the app
Compare config/urls.py with Step 4 and save it. The tests report the same mistake as 404 != 200
Wrong view or 404 for one address
The path or pattern order differs
Compare the address, trailing slash, prefixes, and route order
Compare the view's text and the test, and read the failure before editing either
ImproperlyConfigured: Set DJANGO_SECRET_KEY; see .env.example.
The Chapter 8 .env is missing
See Table 8.4. Do not paste the secret anywhere
Keep your work if a correction is needed. Compare each file with the listing and save a separate copy before replacing anything you want to preserve. If the server has stopped, start it again after correcting the file. Do not delete the project or reset Git to diagnose a route.
Run the checks in Table 9.2 from the folder containing manage.py, with the development server running for the three browser rows.
Table 9.2 — Verification checklist for Chapter 9
Check
Command or action
Expected result
Configuration
uv run python manage.py check
System check identified no issues (0 silenced).
Automated checks, including route names
uv run python manage.py test events
Found 3 test(s). and OK at the end
Home
Open http://127.0.0.1:8000/
Welcome to Otahque.
Event list
Open http://127.0.0.1:8000/events/
Event list coming soon.
Unknown path
Open http://127.0.0.1:8000/does-not-exist/
A 404 page
If any check fails, use Table 9.1 and run the whole test command again after the fix. These checks verify the present routing and placeholder text; they do not establish that event data, registration, permissions, or the full milestone work.
Que. 3 What is the route string for the home address /?
Flip to check your answerFold answer back
Answer. The empty string, ''. The slash in the browser address is not included in the route argument.
Que. 4 Why do we have two files named urls.py?
Flip to check your answerFold answer back
Answer. The project URLconf chooses where to delegate; the events URLconf owns the app’s route patterns. They are in different folders and cooperate through include().
Que. 5 You open /events without the final slash, and the browser ends up at /events/. No route is named events. What happened?
Flip to check your answerFold answer back
Answer. Django’s CommonMiddleware found no match for /events but saw that /events/ would match, so it answered with a redirect, because the APPEND_SLASH setting is on by default. That is why this works in the browser, and why a test that requests /events receives a 301 rather than the page.
Que. 6 What does reverse('events:list') provide?
Flip to check your answerFold answer back
Answer. The path for the named route, /events/, in this configuration. It does not send a request.
Que. 7 Why check content as well as status 200, and why did we watch the tests fail first?
Flip to check your answerFold answer back
Answer. A successful response could still be from the wrong view or contain the wrong text, and a content assertion catches that, although it is not a complete browser or accessibility test. Watching a test fail first shows that it can fail, and that it fails for the reason we expected.
Mini-Challenge
Add a temporary route and trace an address. Work it out before reading the model answer, and remove the temporary route afterwards so that the next chapter starts from the same checkpoint.
Que. 8 Add a temporary welcome/ route in events/urls.py that uses the existing home view and has the name welcome. Visit /welcome/ locally, then trace /events/?page=2 through both URLconfs. What does each show, and does the page value alter the route?
Flip to check your answerFold answer back
Answer. Add path('welcome/', views.home, name='welcome'), inside the app’s urlpatterns. After saving, /welcome/ displays Welcome to Otahque. For /events/?page=2, the project includes events.urls at the empty prefix. The app’s events/ route selects event_list, which returns Event list coming soon. The query string does not change the match, and our current view does not use the page value. Remove only the temporary line and rerun the three tests.
What We Learned
A URL contains several parts; Django’s URL dispatcher matches the request path.
A project URLconf can include an app URLconf, and pattern order affects which view wins.
A named route can be reversed into a path; a view supplies the response.
A test written first and seen to fail shows that it can catch the problem; ., F, and E report each result.
Browser checks and automated tests give different, complementary evidence.
Key terms
Use Table 9.3 to explain routing and testing in your own words.
Table 9.3 — Key terms from Chapter 9
Term
Meaning in this chapter
URL
An address that identifies a resource on the web.
Path
The part of a URL that identifies the requested location on the server.
Routing
Matching a requested path to the code that handles it.
URLconf
A Python module containing URL patterns.
Route
A pattern used to match part of the requested path.
View
Code Django calls to handle a matched request.
Namespace
A prefix used to distinguish related route names.
Reverse
Find a path from a route name and any required arguments.
Test client
Django's tool for simulated requests in tests.
SimpleTestCase
A Django test class for tests that do not use a database.
Readiness checkpoint: you are ready for Chapter 10 when both local pages show their intended text, an unknown address returns 404, and the three tests pass. You should be able to point to the two URLconfs and explain which view /events/ selects, using Figure 9.2 if you need it, and explain what FF. means in a test run. Return to the relevant part if any result is missing.
Git Commit
Once the checks pass, see what changed, in PowerShell, a macOS shell, or Linux/WSL Bash:
Terminal
git status --short
Expected result:
Output
M config/urls.py
M events/tests.py
M events/views.py
?? events/urls.py
M marks a recorded file that has changed. Check that your secret .env is absent from the list. Stage only the four routing files, and read what you have staged; press q to leave the listing:
If you see a secret, stop and follow Chapter 8’s secret recovery guidance in Table 8.4; removing it from a later commit does not erase earlier history. Otherwise, record the commit. No remote or push is needed:
These five questions rehearse the chapter at interview level, one at each of five levels from junior to lead. L1 and L2 check what you have just learned. L3 asks how it works underneath. L4 and L5 look ahead to the larger URL configurations Otahque will need later: attempt them now, and return to them when you reach those chapters. They are extension questions, not a gate to the next chapter. Run each code proof beside manage.py, in PowerShell, a macOS shell, or Linux/WSL Bash. These proofs show our configuration, not every possible Django project.
L1 (Junior): What connects a URL to a view?
What the interviewer is testing: Can you explain the request path without confusing the route with the response?
Flip to check your answerFold answer back
Perfect answer: A URLconf holds patterns that Django checks against the request path, in order. A matching pattern identifies a view, Django calls that view with the request, and the view returns the response. The URLconf only chooses; it renders nothing itself. In Otahque, config/urls.py hands over to events/urls.py, whose events/ pattern selects event_list.
Table 9.4 — Who does what when a request arrives
Part
Its job
URL
Names the resource the browser asks for
URLconf pattern
Matches the path and selects a view
View
Receives the request and returns a response
Response
Carries the status and body back to the browser
Behind the scenes:
django/urls/resolvers.py (summary, not the source)
# URLPattern.resolve(path): if the route matches, return a
# ResolverMatch holding the view and captured values.
# The handler then calls view(request, **captured values).
Code proof: ask Django which view a path selects, without sending a request:
Terminal
uv run python manage.py shell -c "
from django.urls import resolve
match = resolve('/events/')
print(match.func.__name__, match.view_name)
"
“What changes when a view returns a template rather than text?”
“Does the query string take part in the match?”
L2 (Mid-Level): What does include() do?
What the interviewer is testing: Do you understand the handoff from the project to an app?
Flip to check your answerFold answer back
Figure 9.3 — The project delegates the remaining path to the app.
Perfect answer:include() connects another URLconf to a prefix. When the prefix matches, Django removes the matched part and continues with the remaining path against the included patterns. That lets each app own its routes while the project decides where they live. We use an empty prefix, which consumes no characters, so the app sees the whole path. Moving the app to community/ would change every full address in the app and none of its patterns.
Behind the scenes:
django/urls/resolvers.py (summary, not the source)
# URLResolver.resolve(path): match this resolver's prefix,
# then try each pattern with the remaining path.
# Return the first match, or raise Resolver404 listing
# the patterns that were tried.
Code proof: print the patterns at both levels:
Terminal
uv run python manage.py shell -c "
from django.urls import get_resolver
root = get_resolver()
for item in root.url_patterns:
print(repr(str(item.pattern)), type(item).__name__)
for item in root.url_patterns[1].url_patterns:
print(repr(str(item.pattern)), item.name)
"
Output
12 objects imported automatically (use -v 2 for details).
'admin/' URLResolver
'' URLResolver
'' home
'events/' list
Common mistakes:
Adding the same prefix in both files, which gives /events/events/.
Expecting include() to call a view by itself.
Assuming that an empty prefix means the app owns every path.
Follow-up the interviewer might ask:
“What would you change to serve this app under /community/, and what would you test?”
“Does it matter here whether admin comes first?”
L3 (Senior): Why name a route?
What the interviewer is testing: Can you distinguish path resolution from reverse lookup, and explain what a namespace adds?
Flip to check your answerFold answer back
Figure 9.4 — A name is reversed into a path.
Perfect answer: A route name gives code an identifier from which Django can construct the configured path, so links and redirects do not repeat it. If the path changes while the name stays the same, those callers keep working. A namespace separates names belonging to different apps, so two apps can each have a list. A name does not remove every dependency: renaming a route or changing its required arguments still means updating callers, and reverse() raises NoReverseMatch when it cannot build a path, without sending any request.
Behind the scenes:
django/urls/base.py (summary, not the source)
# reverse('events:list'): split the namespace from the name,
# find the resolver registered for that namespace,
# and build the path from its pattern and arguments.
# No match raises NoReverseMatch.
Code proof: reverse the name with its namespace, then without:
Terminal
uv run python manage.py shell -c "
from django.urls import NoReverseMatch, reverse
print(reverse('events:list'))
try:
reverse('list')
except NoReverseMatch as error:
print(type(error).__name__)
"
Treating a route name as if it could never change.
Follow-up the interviewer might ask:
“Can two apps both name a route list?”
“How would you find every caller before renaming a route?”
L4 (Staff): How can route order cause a surprise?
What the interviewer is testing: Can you reason about overlapping patterns before a larger URL configuration makes them hard to see?
Flip to check your answerFold answer back
Figure 9.5 — An earlier successful match determines the view.
Perfect answer: Django uses the first complete match, not the most specific one. A broad pattern placed before a narrower one takes every path they share, and nothing warns you. Our present patterns do not overlap, so their order does not matter yet. Once Otahque gains routes with captured values, such as event pages addressed by a short name, the order becomes a design decision. I would put exact routes first, keep broad patterns behind a distinct prefix, and test the view each concrete address selects, because a shadowed route still returns a response.
Behind the scenes:
django/urls/resolvers.py (summary, not the source)
# for pattern in self.url_patterns:
# match = pattern.resolve(remaining_path)
# if match: return it. Later patterns are never tried.
Code proof: two throwaway URLconfs, used only here, hold the same patterns in opposite orders:
Terminal
uv run python manage.py shell -c "
from django.urls import path, resolve
def broad(request, slug): pass
def exact(request): pass
class BroadFirst:
urlpatterns = [
path('<slug:slug>/', broad),
path('events/', exact),
]
class ExactFirst:
urlpatterns = BroadFirst.urlpatterns[::-1]
for urls in (BroadFirst, ExactFirst):
print(resolve('/events/', urlconf=urls).func.__name__)
"
Testing only the status, which a shadowing view can also return as 200.
Placing a broad pattern at the empty prefix of a shared project URLconf.
Follow-up the interviewer might ask:
“How would you detect a shadowed route in a large project?”
“When would you give a broad pattern its own prefix instead?”
L5 (Lead): A route returns 404. How do you lead the investigation?
What the interviewer is testing: Can you lead a careful diagnosis that preserves evidence and work?
Flip to check your answerFold answer back
Figure 9.6 — Diagnose an unexpected 404 without guessing.
Perfect answer: First record the exact address, method, and response, because a reproduction is worth more than a theory. Next ask what Django tried: compare the path with the project and app patterns in order, and check includes, prefixes, and slashes. If a pattern did match, the view itself may have raised the 404, and the cause is in its data or rules rather than its route. Change one thing at a time, and add a regression test that fails before the fix. I would also ask the team to leave the failing state in place until it is understood, rather than deleting routes to see what happens. Debug output helps locally, but must never be exposed publicly.
Behind the scenes:
django/urls/resolvers.py (summary, not the source)
# When nothing matches, URLResolver raises
# Resolver404({'tried': [...], 'path': path})
# With DEBUG on, the 404 page lists those tried patterns.
Code proof: ask Django what it tried for a path that matches nothing:
Terminal
uv run python manage.py shell -c "
from django.urls import Resolver404, resolve
try:
resolve('/does-not-exist/')
except Resolver404 as error:
for tried in error.args[0]['tried']:
names = [repr(str(p.pattern)) for p in tried]
print(' then '.join(names))
"
Output
12 objects imported automatically (use -v 2 for details).
'admin/'
'' then ''
'' then 'events/'
Common mistakes:
Treating every 404 as a missing route.
Deleting work or changing several routes before capturing the failing address.
Fixing the route without adding a test that would have caught it.
Follow-up the interviewer might ask:
“How do you tell a missing route from a view that raised 404?”
“Does one unknown-path test prove that every invalid path is handled correctly?”
Next: Chapter 10 looks inside a view: the request it receives, the response it returns, and a first detail page for a fictional sample event.