I am creating a custom widget for a datetime field:
class MySplitDateTimeWidget(forms.SplitDateTimeWidget):
def format_output(self, rendered_widgets):
mytimeid = self.widgets[1].attrs['id'] #####NEED HELP HERE
temp = "javascript:$('%s').val(new Date().getHours());" % mytimeid
temp1 = '<a href="%s">Now</a>' % temp
return mark_safe(u'%s %s<br />%s %s %s' % \
(_('Date:'), rendered_widgets[0], _('Time:'), rendered_widgets[1],
temp1
))
I need the "id" attribute of the widget, however self.widgets doesn't include the "id" attribute in attrs. It includes every other attribute though. I'm not sure where this attribute comes from?