[Django]-MaxLength for Integer field in Django

3👍

You can write your own validator, for example:

from django.core.validators import MaxValueValidator

class MaxLengthIntegerValidator(MaxValueValidator):
    def __init__(self, length):
        max_value = 10**length-1
        super(MaxLengthIntegerValidator, self).__init__(max_value)
👤Selcuk

Leave a comment