HPW para crear un modelo relacionado en Django REST Framework Logic
class OrderSerializer(serializers.ModelSerializer):
class Meta:
model = Order
fields = (
'id',
'total',
'discount',
)
def calculate_discount(self, whatever_params):
# calculate discount if you need... and return it
def calculate_tax(self, whatever_params):
# calculate tax amount if you need...and return it
def calculate_grand_total(self, whatever_params):
# calculate grand total if you need and return it
def create(self, validated_data):
# You can make an order by applying
# some logic in the calculation method.
# Maybe by adding a bit of the context
# you sent as parameters from view.
Confused Cormorant