我不明白为什么我不能在get_context_data中调用带有参数的方法。通过删除参数它的工作原理。在发送到模板之前,更改基于类的视图上下文的推荐方法是什么?
class CustomerReportView(TemplateView):
"""Generate Customer Reports based on acct_id"""
def whoami(self, username):
"""
returns following information about the currently logged-in user
{'Name':'', 'Email':''}
"""
records = {'Name':username, 'Email':'john.doe@email.com'}
return records
def get_context_data(self, **kwargs):
context = super(CustomerReportView, self).get_context_data(**kwargs)
context['now'] = self.whoami('john.doe@email.com')
return context