def overview_feed(request, slug):
    survey = get_object_or_404(Survey, home_slug=slug)
    survey_values = ['id','display_chatter','name']
    data = Survey.objects.filter(pk=survey.id).values(*survey_values)[0]
    data['survey_respondents'] = Assignment.objects.filter(survey=survey).count()
    data['surveys_complete'] = Assignment.objects.filter(survey=survey, survey_complete=True).count()
    
    questions = Question.objects.filter(questiongroup__in=QuestionGroup.objects.filter(assignment__survey=survey).distinct()).distinct()
    
    questions_dict = OrderedDict()
    
    data['bin_map'] = { NO_RESPONSE: 'no-response' }
    
    for q in questions:
        new_q_values = ['id', 'question', 'explanation', 'directed_to', 'visualize']
        new_q = Question.objects.filter(pk=q.id).values(*new_q_values)[0]
        
        new_q['asked'] = Assignment.objects.filter(survey=survey, questions__questiongrouporder__question=q).count()
        new_q['answered'] = Answer.objects.filter(assignment__survey=survey, question__question=q).count()
        new_q['no_answer'] = new_q['asked'] - new_q['answered']
        new_q['answers'] = {}
        new_q['bins'] = OrderedDict()
        new_q['order'] = q.order
        
        for a in q.choices.all():
            new_q['answers']['%s' % a.choice] = Answer.objects.filter(assignment__survey=survey, question__question=q, answer=a).count()
            new_q['bins'][a.display.slug] = {'label': a.display.display}
            data['bin_map'][a.choice] = a.display.slug
        
        questions_dict['%s' % str(q.id)] = new_q
        
    data['questions'] = questions_dict
    
    data['feed_updated'] = str(datetime.datetime.now())
    
    data = json.dumps(data, sort_keys=False, indent=4)
    return HttpResponse(data, mimetype='application/json')
Overview feed contains:
dataset/ETHPy150Open newsday/newstools-checkup/checkup/views.py/overview_feed