I want to add to template the media values so in the view I get the value in the get_queryset and then add them to template with get_context, but something is wrong :
class LaLista(ListView):
def get_queryset(self, **kwargs):
qs = super(LaLista, self).get_queryset()
media = qs.aggregate(Avg('A_U'), Max('A_U'), Min('A_U'))
return qs, media
def get_context_data(self, **kwargs):
context = super(LaLista, self).get_context_data(**kwargs)
context['media'] = media
return context
in the template I have given:
{{ media }}
and this will return:
NameError: global name 'media' is not defined