7.11.2 The Last New View (w/ bug fix)
parent
84f6645fc1
commit
d99dd167ac
|
@ -15,3 +15,8 @@ def new_list(request):
|
|||
list_ = List.objects.create()
|
||||
Item.objects.create(text=request.POST['item_text'], list=list_)
|
||||
return redirect(f'/lists/{list_.id}/')
|
||||
|
||||
def add_item(request, list_id):
|
||||
list_ = List.objects.get(id=list_id)
|
||||
Item.objects.create(text=request.POST['item_text'], list=list_)
|
||||
return redirect(f'/lists/{list_.id}/')
|
|
@ -20,5 +20,5 @@ urlpatterns = [
|
|||
url(r'^$', views.home_page, name='home'),
|
||||
url(r'^lists/new$', views.new_list, name='new_list'),
|
||||
url(r'^lists/(\d+)/$', views.view_list, name='view_list'),
|
||||
url(r'^lists/(\d+)/add_item$', views.add_item, new='add_item'),
|
||||
url(r'^lists/(\d+)/add_item$', views.add_item, name='add_item'),
|
||||
]
|
Loading…
Reference in New Issue