基于Django类的视图不返回当前用户详细信息

时间:2013-11-15 06:08:44

标签: django django-views

我正在调用基于类的视图

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'未定义

1 个答案:

答案 0 :(得分:2)

像这样呼叫get_full_name

fullname = user.get_full_name()