def get_context_data(self, **kwargs):
        context = super(EstablishmentDetail, self).get_context_data(**kwargs)
        establishment = context['establishment']
        inspections = establishment.inspections.prefetch_related('violations')
        inspections = inspections.order_by('-date')
        try:
            context['latest'] = inspections.filter(type=1)[0]
        except __HOLE__:
            context['latest'] = None
        context['inspections'] = inspections
        return context
dataset/ETHPy150Open codefordurham/Durham-Restaurants/inspections/views.py/EstablishmentDetail.get_context_data