views.py 434 B

12345678910111213
  1. from django.shortcuts import render, redirect
  2. #from django.http import HttpResponse
  3. from lists.models import Item
  4. def home_page(request):
  5. if request.method == 'POST':
  6. Item.objects.create(text=request.POST['item_text'])
  7. return redirect('/lists/the-only-list/')
  8. return render(request, 'home.html')
  9. def view_list(request):
  10. items = Item.objects.all()
  11. return render(request, 'list.html', {'items': items})