Enable DataclassSerializer to work with property
Closed this issue · 1 comments
EnriqueSoria commented
It looks like DataclassSerializer can't handle properties automatically. It would be great to make this possible:
@dataclass
class PricingInfo:
original_price_incl_tax: Decimal
@property
def original_price(self) -> Decimal:
"""Backwards compatibility"""
return self.original_price_incl_tax
class PricingInfoSerializer(DataclassSerializer):
class Meta:
dataclass = PricingInfo
fields = (
"original_price",
)
The field 'original_price' was included on serializer PricingInfoSerializer in the `fields` option, but does not match any dataclass field.
EnriqueSoria commented
Thanks!