我试图从用户表中获取一些值与同一查询中的组名相结合,但组名始终为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)