0👍
✅
Looks to me like TimeInput inherits from Widget (via TextInput), which accepts attributes in one dictionary as the attrs
argument. The examples with TextInput show use of required:
>>> name = forms.TextInput(attrs={'required': False})
By contrast, Field subclasses such as TimeField and CharField do accept keyword arguments like you use.
4👍
Instead of using required
, try using blank
instead. blank=False
means it’s not required.
time = forms.TimeInput(blank=True)
- [Django]-Django use value of template variable as part of another variable name
- [Django]-Is it possible in django forms to leave Filefield empty?
- [Django]-In Django, how to rename user model?
- [Django]-Django-based skill implementation
- [Django]-Django : AbstractBaseUser And Error =' AttributeError: can't set attribute '
Source:stackexchange.com