def view_month(request, year, month): if request.user.is_authenticated(): month = MonthLog.get_month(year, month, request.user) else: month = MonthLog.get_month(year, month) form = EntryForm(for_list=month.list) if request.method == "POST": form = EntryForm(for_list=month.list, data=request.POST) if form.is_valid(): form.save() return redirect(month) return render(request, 'month.html', {'month': month, 'form': form})
def view_day(request, year, month, day): if request.user.is_authenticated(): month = MonthLog.get_month(year, month, request.user) else: month = MonthLog.get_month(year, month) day = month.get_day(day) form = EntryForm(for_list=day.list) if request.method == "POST": form = EntryForm(for_list=day.list, data=request.POST) if form.is_valid(): form.save() return redirect(day) return render(request, 'day.html', {'day': day, 'form': form})