views.py 417 B

1234567891011121314
  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. return render(request, 'home.html')
  6. def view_list(request):
  7. items = Item.objects.all()
  8. return render(request, 'list.html', {'items': items})
  9. def new_list(request):
  10. Item.objects.create(text=request.POST['item_text'])
  11. return redirect('/lists/the-only-list/')