Ticket #10602: auto_now.diff
File auto_now.diff, 1.2 KB (added by , 16 years ago) |
---|
-
django/db/models/fields/__init__.py
478 478 479 479 def pre_save(self, model_instance, add): 480 480 if self.auto_now or (self.auto_now_add and add): 481 value = datetime.date time.now()481 value = datetime.date.today() 482 482 setattr(model_instance, self.attname, value) 483 483 return value 484 484 else: … … 557 557 raise exceptions.ValidationError( 558 558 _('Enter a valid date/time in YYYY-MM-DD HH:MM[:ss[.uuuuuu]] format.')) 559 559 560 def pre_save(self, model_instance, add): 561 if self.auto_now or (self.auto_now_add and add): 562 value = datetime.datetime.now() 563 setattr(model_instance, self.attname, value) 564 return value 565 else: 566 return super(DateTimeFieldField, self).pre_save(model_instance, add) 567 560 568 def get_db_prep_value(self, value): 561 569 # Casts dates into the format expected by the backend 562 570 return connection.ops.value_to_db_datetime(self.to_python(value))