📜  python django 模型范围验证 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:19.623000             🧑  作者: Mango

代码示例1
from django.db import models
from django.core.validators import MaxValueValidator, MinValueValidator

class MyModel(models.Model):
    qty = models.IntegerField(
        default=1,
        validators=[MaxValueValidator(100), MinValueValidator(1)]
     )