[Django]-__init__() got an unexpected keyword argument 'required'

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)

Leave a comment