Closed pmg103 closed 4 years ago
Here is a workaround until we fix it:
{'product_variant': [
'id',
'name',
# Plugin necessary to work around SSM bug where two M2M fields conflict:
{'comparison_groups': ProductVariantComparisonGroups()},
'report_templates',
]},
class ProductVariantComparisonGroups(SerializationSpecPlugin):
def modify_queryset(self, queryset):
return queryset.prefetch_related(Prefetch('comparison_groups', to_attr='_comparison_groups'))
def get_value(self, instance):
return [each.id for each in instance._comparison_groups]
Maybe it only happens if there's another outer layer of nesting?
Maybe it only happens if there's another outer layer of nesting?
Nope, tried that too and it still appears to work 🤔
When requesting two id-lists for two M2M fields, they both end up being the same list (of the last one requested, in this case the list of
report_templates
)View:
Output: