TypeError:'instancemethod'类型的对象没有len()
我刚把我的项目整理完。把一些没用的应用和代码删掉了,然后把剩下的整理了一下。结果我遇到了一个错误。
TypeError: object of type 'instancemethod' has no len()
所以我把它改成了count(),但又遇到了另一个错误。
AttributeError: 'function' object has no attribute 'count'
这是我的代码:
def budget(request):
envelopes = Envelope.objects.filter(
user=request.user).exclude_unallocated
return render(request, 'budget.html', {
'limit': account_limit(request, 15, envelopes),
}
def account_limit(request, value, query):
count_objects = len(query)
//other codes here
return result
我觉得我在这里删掉了什么东西,所以才会出现这个错误。
1 个回答
10
你忘了加上()了
envelopes = Envelope.objects.filter(user=request.user).exclude_unallocated()