In your
Transfermodel, in the transaction ForeignKey, addrelated_name=transfers.In your
TransactionSerializer, add the class attribute:
transfers = TransferSerializer(many=True)
This will give you:
- EDIT: In your
TransferSerializer, modifyfieldsforfields=('created_at','transaction_type_id', 'transfers')This will give you:
{
"created_at": "2019-08-18",
"transaction_type_id": "1",
"transfers": [
{"transfer_type": 1, "debit": "100", ...},
...
],
}