15 lines
457 B
Python
Raw Normal View History

2020-11-09 11:57:23 +11:00
from django.shortcuts import redirect, render
2020-11-09 11:16:18 +11:00
from lists.models import Item
# Create your views here
def home_page(request):
2020-11-09 11:16:18 +11:00
if request.method == 'POST':
2020-11-09 11:57:23 +11:00
Item.objects.create(text=request.POST['item_text'])
2020-11-10 23:56:56 +11:00
return redirect('/lists/the-only-list-in-the-world')
2020-11-09 11:16:18 +11:00
return render(request=request, template_name='home.html')
2020-11-11 13:33:55 +11:00
def view_list(request):
items = Item.objects.all()
return render(request, 'list.html', {'items': items})