def _from_python(self, value, state): """ returns a string using the correct grouping """ dec_places = util.find_precision(value) if dec_places > 0: return format.format_decimal(value, dec_places) else: return format.format_number(value)
def _from_python(self, value, state): """Return a string using the correct grouping.""" dec_places = util.find_precision(value) if dec_places > 0: return format.format_decimal(value, dec_places) else: return format.format_number(value)
def _from_python(self, value, state): """Return a string using the correct grouping. If the validator was instantiated with a decimals parameter, this is used for the number of decimals. If None ist given, the number of decimals is determined by the value itself. """ if self.decimals is None: decimals = util.find_precision(value) else: decimals = self.decimals if decimals > 0: return format.format_decimal(value, decimals) else: return format.format_number(value)