Changing default datetime widget value in blank field

22 views
Skip to first unread message

mcamel

unread,
Feb 27, 2014, 10:40:00 AM2/27/14
to web...@googlegroups.com
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()


Reply all
Reply to author
Forward
0 new messages