![Show Menu](styles/mobile-menu.png)
![Page Background](./../common/page-substrates/page0124.png)
lists/views.py.
def
home_page
(
request
):
return
render
(
request
,
'home.html'
)
Yep!
OK
And while we’re at it, we can remove the now-redundant
test_home_page_on
ly_saves_ items_when_necessary
test too!
Doesn’t that feel good? The view functions are looking much simpler. We rerun the tests
to make sure…
Ran 7 tests in 0.016s
OK
Pointing Our Forms at the New URL
Finally, let’s wire up our two forms to use this newURL. In
both home.html
and
lists.html
:
lists/templates/home.html, lists/templates/list.html.
<form
method=
"POST"
action=
"/lists/new"
>
And we rerun our FTs to make sure everything still works, or works at least as well as
it did earlier…
AssertionError:
'http://localhost:8081/lists/the-only-list-in-the-world/' ==
'http://localhost:8081/lists/the-only-list-in-the-world/'
Yup, we get to the same point we did before. That’s a nicely self-contained commit, in
that we’ve made a bunch of changes to our URLs, our
views.py
is looking much neater
and tidier, and we’re sure the application is still working as well as it did before. We’re
getting good at this refactoring malarkey!
$
git status
# 5 changed files
$
git diff
# URLs for forms x2, moved code in views + tests, new URL
$
git commit -a
And we can cross out an item on the to-do list:
96
|
Chapter 6: Getting to the Minimum Viable Site