ValueError:字典更新序列元素#0的长度为28; 2个为必填项

时间:2019-03-19 17:46:43

标签: python django

我在django视图之一中遇到此错误。这是什么意思?我该如何解决?下面是出现错误的视图,

def duedate(request):
    data = Task.objects.all()
    total_count = data.count()
    pending_count = 0
    for dat in data:
        if dat.done == False:
            pending_count += 1
    today = datetime.date.today()
    context = {'data':data, 'today':today, 'count':total_count, 'pending':pending_count}
    return render(request, 'todoapp/index.html', context)

编辑1: 这就是我“ ipdb”字典时得到的东西

         36     import ipdb; ipdb.set_trace()
         37     context = {'data':data, 'today':today, 'count':total_count, 'pending':pending_count}
    ---> 38     return render(request, 'todoapp/index.html', context)

    ipdb> context                                                                                                                                         
    {'data': <QuerySet [<Task: Finish todo list>, <Task: create views to display due date>]>, 'today': datetime.date(2019, 3, 19), 'count': 2, 'pending': 2}

1 个答案:

答案 0 :(得分:0)

问题出在settings.py文件中。我向模板添加了自定义模板标签。我只需要删除它。