I'm still learning how to use all these widges in Django. The first one I tried out was the date and time widgets for date and time fields. Turns out it was fairly simple to do so. I didn't need to use any Javascript at all. It took me awhile to understand that widgets are basically a representation of HTML input elements. So the attributes are determined by the HTML inputs. Initially I kept wondering where these attributes came from because they were not spelled out in the Django documentation. Silly me :P models.py Date = models.DateField( default = None ) Time = models.TimeField( default = "12:00" ) forms.py class MyForm(ModelForm): class Meta: model = MyModel widgets = { 'Date' : forms.DateInput( attrs ={ 'type' : 'date' }) , 'Time' : forms.TimeInput( attrs ={ 'type' : 'time' }) , }
This is me documenting my progress as a programmer. I foresee much excitement, much frustration and much cats. Always, cats.