def set_manufacturer_filter(request, category_slug, manufacturer_id):
    """ Saves the given manufacturer filter to session. Redirects to the category with given slug.
    """
    try:
        manufacturer_id = int(manufacturer_id)
        if Manufacturer.objects.filter(pk=manufacturer_id).exists():
            mf = request.session.get("manufacturer-filter", [])
            if manufacturer_id not in mf:
                mf.append(manufacturer_id)
            request.session["manufacturer-filter"] = mf
    except (__HOLE__, TypeError) as e:
        pass

    url = reverse("lfs_category", kwargs={"slug": category_slug})
    return HttpResponseRedirect(url)
dataset/ETHPy150Open diefenbach/django-lfs/lfs/catalog/views.py/set_manufacturer_filter