# url(r'^admin/', include(admin.site.urls)),
)
Three very similar-looking URLs there. Let’s make a note on our to-do list; they look
like good candidates for a refactoring.
•
Get FTs to clean up after themselves
•
Adjust model so that items are associated
with different lists
•
Add unique URLs for each list
•
Add a URL for creating a new list via POST
•
Add URLs for adding a new item to an
existing list via POST
•
Refactor away some duplication in urls.py
Back to the tests, we now get:
django.core.exceptions.ViewDoesNotExist: Could not import lists.views.add_item.
View does not exist in module lists.views.
The Last New View
Let’s try:
lists/views.py.
def
add_item
(
request
):
pass
Aha:
TypeError: add_item() takes 1 positional argument but 2 were given
lists/views.py.
def
add_item
(
request
,
list_id
):
pass
And then:
ValueError: The view lists.views.add_item didn't return an HttpResponse object.
It returned None instead.
One More View to Handle Adding Items to an Existing List
|
107