django:查询用户时无法获取组名

时间:2014-11-11 11:03:50

标签: python django

我试图从用户表中获取一些值与同一查询中的组名相结合,但组名始终为None

class UsersView(View):
    def get(self, request):
        context = dict()
        users = User.objects.select_related().all()
        context['users'] = users.values('last_login', 'username', 'email', 'is_active', 'date_joined', 'groups__name')
        return render_to_response('users.html',
                                  context,
                                  context_instance=RequestContext(request)

0 个答案:

没有答案