in apps.dashboard.tests & .urls, adding a new to-do item to the input field in either home.html or a blank-tabled list.html points to /apps/dashboard/newlist; in .views, home_page() FBV simplified to a mere html page render & new_list() FBV added that currently points to the global list
This commit is contained in:
@@ -2,13 +2,12 @@ from django.shortcuts import redirect, render
|
||||
from .models import Item
|
||||
|
||||
def home_page(request):
|
||||
if request.method == 'POST':
|
||||
Item.objects.create(text=request.POST['item_text'])
|
||||
return redirect('/apps/dashboard/the-only-list-in-the-world/')
|
||||
|
||||
items = Item.objects.all()
|
||||
return render(request, 'apps/dashboard/home.html', {'items': items})
|
||||
return render(request, 'apps/dashboard/home.html')
|
||||
|
||||
def view_list(request):
|
||||
items = Item.objects.all()
|
||||
return render(request, 'apps/dashboard/list.html', {'items': items})
|
||||
return render(request, 'apps/dashboard/list.html', {'items': items})
|
||||
|
||||
def new_list(request):
|
||||
Item.objects.create(text=request.POST['item_text'])
|
||||
return redirect('/apps/dashboard/the-only-list-in-the-world/')
|
||||
|
||||
Reference in New Issue
Block a user