I have a Django models with a DurationField. I would like that the users cannot put a value over 00:09:59. Unfortunately I could not find any information to do this in the doc : https://docs.djangoproject.com/en/4.1/ref/models/fields/#durationfield
Question posted in PostgreSQL
The official documentation can be found here.
The official documentation can be found here.
2
Answers
You can add validators for that.
It will look something like:
It is not possible with default
DurationField
.You can override the
clean_%s
method in the form:If you need to do this validation in many places, you can create a custom Field for overriding the validating method of field: