Set the default of a DateTime Field to the current date/time
The default behavior for my ATs was that a DateTimeField using the CalendarWidget would only have the year filled in. I wanted the value to be set to the current date and time. I had no special requirements for accuracy, time zones, etc.
The three step process is:
1) Add this line to the area where you declare imported modules. Note that I am lazy and used the asterisk. You might be more conscientious and actually import the specific module necessary:
from DateTime.DateTime import *
2) In the Schema, make a DateTimeField and specify a default_method to populate the field:
DateTimeField('dateAdded',
searchable = 1,
required = 0,
default_method = 'getDefaultTime',
widget = CalendarWidget(
label = 'Date Added'
),
),
3) In the class definition code, skip to near the bottom and add a new method called getDefaultTime:
def getDefaultTime(self): return DateTime()
That's it. Your new instances should now be populated with something that approximates the current date and time.

Author: