0
I have a field in my admin Django that receives a real value, but I would like that value to be formatted and not receive more than two decimal places.
I tried using a javascript to modify the Django admin page, but this generates many side effects:
let valor = document.querySelector('#id_valor');
let oldVal = '';
valor.addEventListener('keyup', function(){
let parts = this.value.split('.');
console.log(parts)
if (parts && parts[1] && parts[1].length > 3)
this.value = oldVal;
oldVal = this.value;
});
Is there any better way to do this on Jango?
I already have this decimal_places active, I wish the user could not type more decimal places, so he does not even see this error.
– Leonardo Furtado
Try using this https://igorescobar.github.io/jQuery-Mask-Pluginplugin
– Carlos Cortez