-3

I am writing a model in django. I want to set a maximum number for a positiveintegerfield. How can I do that?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • 2
    Possible duplicate of [How to limit the maximum value of a numeric field in a Django model?](https://stackoverflow.com/q/849142/1165509) – marcanuy Jul 22 '19 at 16:16

1 Answers1

0

This should do it: models.PositiveIntegerField(min_value=0, validators=[MaxValueValidator(100),])

More info in the Django docs: https://docs.djangoproject.com/en/2.2/ref/validators/#maxvaluevalidator

Hagyn
  • 922
  • 7
  • 14