Commit 2b168da7 authored by James Esguerra's avatar James Esguerra

Added function to display list of items in today template

parent 94437e7f
......@@ -12,4 +12,5 @@ urlpatterns = [
path('edit_itemTW/<int:pk>', views.ShowEditItemTW, name='edit_itemTW'),
path('delete_itemTW/<int:pk>', views.ShowDeleteItemTW, name='delete_itemTW'),
path('today/', views.ShowToday, name='today'),
path('add_itemT', views.ShowAddItemT, name='add_itemT'),
]
import datetime
from django.shortcuts import render, redirect
from django.http import HttpResponse
from .forms import HomeForm, KeyForm, ItemsThisWeekForm
from .models import Key, ItemsThisWeek
from .forms import HomeForm, KeyForm, ItemsThisWeekForm, ItemsTodayForm
from .models import Key, ItemsThisWeek, ItemsToday
def ShowHome(request):
......@@ -77,4 +77,16 @@ def ShowDeleteItemTW(request, pk):
def ShowToday(request):
return render(request, 'today.html')
item_list = ItemsToday.objects.all()
return render(request, 'today.html', {'item_list': item_list})
def ShowAddItemT(request):
form = ItemsTodayForm()
if request.method == 'POST':
form = ItemsTodayForm(request.POST)
if form.is_valid():
form.save()
return redirect('today')
return render(request, 'add_itemT.html', {'form': form})
{% extends 'base.html' %}
{% load static %}
{% block title %} Key {% endblock %}
{% block header %} Key {% endblock %}
{% block content %}
<form action='' method='POST'>
{% csrf_token %}
{{ form }}
<input type='submit' name='Submit' value='Add'>
</form>
{% endblock %}
......@@ -10,7 +10,12 @@
<div id='today'>
<h2>04.14.WED</h2>
<br>
<button type='button'> Add Item </button>
{% for item in item_list %}
<p>
<b>{{ item.key_type }}:</b> {{ item.details }}
<p>
{% endfor %}
<a href='{% url 'add_itemT' %}'><button type='button'> Add Item </button></a>
</div>
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment