视图myapp.views.home没有返回HttpResponse对象。它返回None

时间:2019-06-14 15:48:25

标签: python django

am尝试使用django创建待办事项列表,但是由于某些原因,当我尝试在屏幕上显示日期时出现此错误

视图myapp.views.home没有返回HttpResponse对象。它返回None。

我的密码

from django.shortcuts import render, redirect
from .models import List
from .forms import ListForm
from django.contrib import messages


def home (request):
    if request.method == 'POST':
        form = ListForm(request.POST)

        if form.is_valid():
            form.save()
            all_items = List.objects.all
            messages.success (request, ('Item has Been Added to List!'))
            return render (request, 'home.html', {'all_items': all_items})

    else:
        all_items = List.objects.all
        return render(request, 'home.html', {'all_items': all_items})

0 个答案:

没有答案