我正在调用基于类的视图
class CurrentUser(APIView):
authentication_classes = (authentication.TokenAuthentication,)
def get(self, request, format=None):
for user in User.objects.all()
if request.user.is_authenticated():
fullname = get_full_name(user)
return Response(fullname)
来自网址的
url(r'^currentuser$', views.CurrentUser.as_view(), name='current-user'
但它返回错误如下..
/ currentuser上的NameError 全局名称'get_full_name'未定义
答案 0 :(得分:2)
像这样呼叫get_full_name
。
fullname = user.get_full_name()