Django

Code

Ticket #1584: auto_now_add_fix.diff

File auto_now_add_fix.diff, 0.5 kB (added by Andy Dustman <farcepest@gmail.com>, 2 years ago)

Bug fix (against magic-removal)

  • django/db/models/fields/__init__.py

    old new  
    423423        return Field.get_db_prep_lookup(self, lookup_type, value) 
    424424 
    425425    def pre_save(self, value, add): 
    426         if self.auto_now or (self.auto_now_add and add): 
     426        if self.auto_now or (not value and self.auto_now_add and add): 
    427427            return datetime.datetime.now() 
    428428        return value 
    429429