Source

ultrasound / django_ultrasound / employees / reports.py

from django.shortcuts import render_to_response
from django.contrib.auth.decorators import login_required
from employees.models import Employee

@login_required
def list_employees(request):
    employees = Employee.objects.all()#.order_by('employee_type')
    employees_by_type = {}
    for employee in employees:
        et = employee.employee_type
        employees_by_type.setdefault(et, [])
        employees_by_type[et].append(employee)
    types = employees_by_type.items()
    return render_to_response('list_employees_report.html', locals())