Fakultas Ilmu Komputer UI

views.py 314 Bytes
Newer Older
1
2
from django.shortcuts import redirect, render
from lists.models import Item
3

4

5
def home_page(request):
6
7
8
9
10
11
    if request.method == 'POST':
        Item.objects.create(text=request.POST['item_text'])
        return redirect('/')

    items = Item.objects.all()
    return render(request, 'home.html', {'items': items})