views.py 350 B

1234567891011
  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('/')
  8. items = Item.objects.all()
  9. return render(request, 'home.html', {'items': items})