Skip to content

Instantly share code, notes, and snippets.

@m5wdev
Last active November 16, 2018 20:38
Show Gist options
  • Save m5wdev/4388a3b82c93f7055b5377fff171c518 to your computer and use it in GitHub Desktop.
Save m5wdev/4388a3b82c93f7055b5377fff171c518 to your computer and use it in GitHub Desktop.
Django 2.* positive integers validation
from django.core.validators import MaxValueValidator, MinValueValidator
class SomeModel(models.Model):
# ...
posiitive_integer = models.PositiveIntegerField(verbose_name='Some amount from 0 to 100', help_text='from 0 to 100', validators=[MinValueValidator(0), MaxValueValidator(100)])
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment