Answer the question
In order to leave comments, you need to log in
Django. Is it possible in django-orm to set a minimum value for a field of type FloatField in a model?
There is a table with prices in the database. Created it through the jago model. The price field is a FloatField. The model is registered with django-admin. When adding\changing values through j-admin, values < 0 can be specified in this table. Is it possible to put some kind of flag so that only values \u003e 0.1 can be added to j-admin?
Answer the question
In order to leave comments, you need to log in
from django.core import validators
price = models.FloatField(..., validators=[validators.MinValueValidator(0.1)])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question