Changes between Version 2 and Version 3 of Ticket #28715
- Timestamp:
- Oct 23, 2017, 5:53:37 AM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #28715 – Description
v2 v3 62 62 if self.connection.features.requires_literal_defaults: 63 63 diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py 64 index 8d40c77..2f5d5c2 100644 64 65 --- a/django/db/models/fields/__init__.py 65 66 +++ b/django/db/models/fields/__init__.py … … 69 70 if self.auto_now_add: 70 71 - kwargs['auto_now_add'] = True 71 + kwargs['default'] = timezone.now72 + kwargs['default'] = datetime.date.today 72 73 if self.auto_now or self.auto_now_add: 73 74 del kwargs['editable'] 74 75 del kwargs['blank'] 76 @@ -1372,6 +1372,12 @@ class DateTimeField(DateField): 77 78 return [] 79 80 + def deconstruct(self): 81 + name, path, args, kwargs = super(DateTimeField, self).deconstruct() 82 + if self.auto_now_add: 83 + kwargs['default'] = timezone.now 84 + return name, path, args, kwargs 85 + 86 def get_internal_type(self): 87 return "DateTimeField" 88 75 89 }}}