Hello,
Does anoybody knows how to alter the default value of the datetime widget in a blank datetime field?.
I think it sets to the actual time in the timezone of the operating system. That's fine almost always, but no when the timezone of the application differs from the one of the system.
A workaround is to set a default value for the field (e.g. adding default=request.utcnow), but i would like to leave the field blank by default to enforce some behaviour on the user.
My goal is to have the same initial value of the widget at these two fields:
def tzform():
import pytz
tz = pytz.timezone('America/Chicago') # use pytz.timezone('Europe/Madrid') if you live in America
form = SQLFORM.factory(
Field('dt1', 'datetime', requires=IS_DATETIME(timezone=tz)),
Field('dt2', 'datetime', requires=IS_DATETIME(timezone=tz), default=request.utcnow,)
)
return locals()