def index(request, cls=None, slug=None):
    context = {
        'classes': Kind.CLS.choices,
    }

    herbs = Herbarium.objects.select_related('kind')
    if cls:
        cls_ids = [i for i, name in Kind.CLS.choices]
        cls = int(cls)
        if cls not in cls_ids:
            raise Http404
        else:
            cls_slug = Kind.cls_slug(cls)
            if cls_slug != slug:
                return HttpResponsePermanentRedirect(
                    reverse('herbarium:filter', args=[cls, cls_slug])
                )

            herbs = herbs.filter(kind__cls=cls)
            context['filter'] = cls

    context['index'] = herbs
    return render(request, 'fruit/herbarium.html', context)
dataset/ETHPy150Open jsmesami/naovoce/src/fruit/herbarium/views.py/index/original