[Answered ]-Products catalogue: filter by parameters

2👍

Start with listing all Features for given product:

product = Product.objects.get(pk=given_pk)
features = product.feature_set.all().select_related()

Now group your features directly in Python.

features_dict = {}
for feature in features:
    values = features_dict.get(feature.name.name, [])
    features_dict[feature.name.name] = values + [feature.value.value]

That will give you dict linking all name to it’s existing values.

Leave a comment