class DateTimeFluxCapacitor(models.DateTimeField): def __init__(self,verbose_name = None, name = None, flux_day = 0, flux_hour = 0, flux_minute = 0, flux_second = 0 , **kwargs): self.flux_day , self.flux_hour , self.flux_minute , self.flux_second = flux_day , flux_hour , flux_minute , flux_second if self.flux_day or self.flux_hour or self.flux_minute or self.flux_second: kwargs['blank'] = True kwargs['editable'] = False super(DateTimeFluxCapacitor,self).__init__(verbose_name,name,False,False) def pre_save(self,model_instance,add): if self.flux_day or self.flux_hour or self.flux_minute or self.flux_second: value = datetime.datetime.now() + datetime.timedelta(days = self.flux_day , hours = self.flux_hour , minutes = self.flux_minute , seconds = self.flux_second ) setattr(model_instance,self.attname,value) return value else: return super(DateTimeFluxCapacitor,self).pre_save(model_instance,add) def get_internal_type(self): return "DateTimeField"