我有这样的功能friend_exists
:
def friend_exists(request, pid):
result = False
try:
user = Friend.objects.get(pid=pid)
except Friend.DoesNotExist:
pass
if user:
result = True
return result
我从我的其他函数中调用它,如下所示:
exists = friend_exists(form.cleaned_data['pid'])
哪里pid = u'12345678'
。为什么我得到:
Exception Type: TypeError at /user/register/
Exception Value: friend_exists() takes exactly 2 arguments (1 given)
有任何想法吗?