from django.newforms import DateTimeField, TimeField from django.newforms.util import ValidationError import datetime class TodayDateTimeField(DateTimeField): ''' DateTimeField which sets today's date if only time was entered ''' def clean(self, value): try: t = TimeField().clean(value) except ValidationError: # try parent's constructor return super(TodayDateTimeField,self).clean(value) else: return datetime.datetime.combine(datetime.date.today(),t)