MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / to_python

Method to_python

mongoengine/fields.py:465–476  ·  view source on GitHub ↗
(self, value)

Source from the content-addressed store, hash-verified

463 super().__init__(**kwargs)
464
465 def to_python(self, value):
466 # Convert to string for python 2.6 before casting to Decimal
467 try:
468 value = decimal.Decimal("%s" % value)
469 except (TypeError, ValueError, decimal.InvalidOperation):
470 return value
471 if self.precision > 0:
472 return value.quantize(
473 decimal.Decimal(".%s" % ("0" * self.precision)), rounding=self.rounding
474 )
475 else:
476 return value.quantize(decimal.Decimal(), rounding=self.rounding)
477
478 def to_mongo(self, value):
479 if self.force_string:

Callers 1

to_mongoMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected