heljhumenad
2/19/2020 - 3:37 AM

Django get_context_data

Details for get_context_data method and example


class AccountIndexView(LoginRequiredMixin, generic.TemplateView):
    template_name = 'accounts/index.html'
    models = EmployeeProfile

    def get_context_data(self, **kwargs):
        context = super(AccountIndexView, self).get_context_data(**kwargs)
        context['employee'] = EmployeeProfile.employee.count()
        context['absent'] = Absent.absents.count()
        context['late'] = Lates.objects.count()
        return context