So, we have CharField() as model field in Django. Then we want to validate input into number only.
Usually, we using obj.is_digit() to validate.
Common mistake happen when we using int() to convert string input.
1 2 | value = "0123123123" int(value) |
Will return
1 | "123123123" |
So becareful when using int() or Decimal() for converting value with leading zero