I have a decimal field in mongoengine, and I am trying to return the data I have stored in the model, but when I try to return the object I am receiving an error in the encoding
TypeError: Object of type 'Decimal' is not JSON serializable
class PaymentTransactionSchema(Document):
meta = {
'collection': 'payment_transaction'
}
payment_mode = StringField()
payment_reference_code = StringField()
currency = StringField()
amount = DecimalField()
status = StringField()
approval_code = StringField()
remarks = StringField()
createdate = DateTimeField(default=datetime.datetime.utcnow)
class ProjectFundTransaction(ModelSchema):
class Meta:
model = ProjectFundTransactionSchema
then a return like this
self.__transaction = PaymentTransactionSchema(**args)
res = self.__transaction.save()
transaction = self.dump(res).data
I was hoping that the marshmallow would handle this automatically but it seems that I missed a config somewhere