Reputation: 13
I have some example model with field:
class Task(models.Model):
priority = models.IntegerField(default=30, validators=[MinValueValidator(0), MaxValueValidator(300)])
When I create a ModelForm
object by modelform_factory()
function and generate html with .as_table()
function then for this field I get something like:
<input type="number" name="priority" value="30" required="" id="id_priority">
But I would like the output to look like this:
<input type="number" name="priority" value="30" required="" id="id_priority" min="0" max="300">
What is the best way to do that?
Upvotes: 1
Views: 422
Reputation: 2688
have you added proper Import ?
from django.core.validators import MaxValueValidator, MinValueValidator
priority = models.IntegerField(default=30, validators=[MinValueValidator(0), MaxValueValidator(300)])
Upvotes: 1