id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 19454 Wrong date in the fields DateTimeField with auto_now_add Wojciech Banaś nobody "Example: {{{ class ExampleModel(models.Model): date_update = models.DateTimeField(auto_now=True) date_create = models.DateTimeField(auto_now_add=True) }}} Let's create an object: {{{ > obj = ExampleModel() > print obj.date_create # Should not be here already set the date of creation of the object? None > obj.save() > assert obj.date_update == obj.date_create *** AssertionError: }}} Conclusion: auto_now_add - Creates a field with unspecified date The documentation tells us: ''DateField.auto_now_add Automatically set the field to now when the object is first created. Useful for creation of timestamps. Note that the current date is always used; it's not just a default value that you can override.'' If we mean by creating an object: {{{ > new_object = ExampleModel() # then we should get > print new_object.date_create # datetime.datetime object with creation date }}} If, however, the creation of an object is the time to save it to the database, then you should get something like this: {{{ > obj = ExampleModel() > print obj.date_create # in this case it is correct None > obj.save() > assert obj.date_update == obj.date_create # == True }}}" Cleanup/optimization closed Database layer (models, ORM) 1.4 Normal duplicate auto_now_add auto_now DateTimeField Unreviewed 0 0 0 0 0 0