【发布时间】:2013-05-09 08:57:02
【问题描述】:
我的代码是这样的: 我自定义了我的上下文并想访问我在模板中设置的查询
class GetStudentQueryHandler(ListView):
template_name = 'client.html'
paginate_by = STUDENT_PER_PAGE
context_object_name = 'studentinfo'
def get_context_data(self, **kwargs):
context = super(GetStudentQueryHandler, self).get_context_data(**kwargs)
context['can_show_distribute'] = self.request.user.has_perm('can_show_distribute_page')
context['form'] = QueryStudentForm
return context
def get_queryset(self):
问题是:如何访问模板中get_queryset方法返回的查询集? 我知道我可以访问studentinfo.can_show_distribute等自定义属性,如何访问查询数据?
【问题讨论】:
标签: django templates django-queryset django-context